如何构建最新的clang-tidy?

新手上路,请多包涵

我试图从 源代码 构建clang-tidy,但它抱怨未定义的CMake命令:

 CMake Error at clang-apply-replacements/CMakeLists.txt:5 (add_clang_library):
  Unknown CMake command "add_clang_library".

CMake Warning (dev) in CMakeLists.txt:
  No cmake_minimum_required command is present.  A line of code such as

    cmake_minimum_required(VERSION 3.9)

  should be added at the top of the file.  The version specified may be lower
  if you wish to support older CMake versions for this project.  For more
  information run "cmake --help-policy CMP0000".
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring incomplete, errors occurred!

如何构建 clang-tidy 或者如何在 macOS 上安装最新版本?

原文由 ruipacheco 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.1k
2 个回答

编辑:这个答案已经过时了——LLVM 项目已移至 https://github.com/llvm/llvm-project 的单个 git 存储库。请参阅下面的答案以获取更新的说明。


clang-tidy 旨在构建 llvm/clang 的签出中,并依赖于 llvm 项目中的 CMake 宏。您应该查看 llvm 存储库,然后检查内部的 clang 存储库 llvm/tools/clang然后 检查内部的 clang-tools-extra 存储库 llvm/tools/clang/tools/extra 。然后您可以在顶级目录上运行 CMake,并且 make clang-tidy 应该可以工作。

如果您对自己构建它不感兴趣,看起来 LLVM 的 Homebrew 公式还包括额外的工具: https ://github.com/Homebrew/homebrew-core/blob/382d3defb5bc48ce2dccd17261be70c4ada9a124/Formula/llvm.rb#L181

原文由 jtbandes 发布,翻译遵循 CC BY-SA 4.0 许可协议

最新步骤:

 git clone https://github.com/llvm/llvm-project.git
cd llvm-project
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" ../llvm
make install clang-tidy

参考、忍者和其他细节: 我自己的博客文章。

原文由 YvesgereY 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题