Search code examples
c++linuxcompilationclang

Using clang-tools but not CMake, is it possible?


I would like to use some clang tools (e.g clang-tidy and clang-doc), however, these tools seem to be directly dependent on CMake.

In either case you need to configure your build using CMake to use clang tools.

I dogmatically don't use CMake so it's either finding a way a around or not using these tools at all. Are there any libraries that can generate the compilation database or is there a way to generate it on your own?


Solution

  • I don't know if this applies to all tools, but as far as I know, at least clang-tidy only uses the compile command database i.e. the compile_commands.json file. As such, it hardly depends on CMake directly at all. The LLVM project uses CMake to generate the compile command database, but you can create it yourself without the help of CMake. The format is quite simple and is specified in the LLVM documentation.

    The compilation command database isn't even required though. You can specify the compilation commands when invoking the tool on command line. But the database is much more convenient.