我试图从 源代码 构建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 许可协议
编辑:这个答案已经过时了——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