I've tried to build clang-tidy from sources but it complains about an undefined CMake command:
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!
How can I build clang-tidy or, alternatively, how can I install the latest version on macOS?
The most convenient way to run clang-tidy is with a compile command database; CMake can automatically generate one, for a description of how to enable it see How To Setup Tooling For LLVM.
You can install clang-format and git-clang-format via npm install -g clang-format . To automatically format a file according to Electron C++ code style, run clang-format -i path/to/electron/file.cc . It should work on macOS/Linux/Windows.
Clang 14, the latest major version of Clang as of March 2022, has full support for all published C++ standards up to C++17, implements most features of C++20, and has initial support for the upcoming C++23 standard.
Up-to-date steps:
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-tools-extra" ../llvm make install clang-tidy
Reference, ninja, and other details: my own blog post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With