clang libTooling instructions say that cmake is required to build the tools and clang?

I’ve built and installed clang, but did so in the “typical” unix way:

mkdir build
cd build
…/llvm/configure --prefix=…
make
make install

The libtooling instructions here say that to use libtooling, you have to build clang using CMake:

http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html

However, it appears all the libtooling stuff is already build by the make that I’ve invoked, so I wouldn’t think that I have to re-build clang a second time to use libtooling.

Is the cmake dependency for clang tools just the requirement to generate this compilation database (this .json file). If so, wouldn’t the requirement be to do this for the project code that I want to run the tools on, not the clang or llvm build tree itself?

Hi,

I believe you are correct. I’m certain that for LLVM and Clang is absolutely does not matter how you build them (in different circumstances, I built them with both methods). However, Clang tools require a CompilationDatabase, which can either be populated manually from other sources (where I work, we use a custom file format for this) or from the somewhat more convenient JSON compilation database that CMake is able to generate automatically. (There also exists another tool which is capable of generating such a .json file even when you’re not using CMake - I don’t remember the name, but I found a reference to it in the Clang documentation somewhere.)

So yeah, it does not matter how you build Clang, and neither does it matter how you build the target application - all that matters is that you need a CompilationDatabase for Clang to be able to work its magic.

Gabor

Hi,

I believe you are correct. I'm certain that for LLVM and Clang is
absolutely does not matter how you build them (in different circumstances,
I built them with both methods). However, Clang tools require a
CompilationDatabase, which can either be populated manually from other
sources (where I work, we use a custom file format for this) or from the
somewhat more convenient JSON compilation database that CMake is able to
generate automatically. (There also exists another tool which is capable of
generating such a .json file even when you're not using CMake - I don't
remember the name, but I found a reference to it in the Clang documentation
somewhere.)

So yeah, it does not matter how you build Clang, and neither does it
matter how you build the target application - all that matters is that you
need a CompilationDatabase for Clang to be able to work its magic.

Technically you don't even need the compilation database (although it makes
things much easier). For tools built according to the standard pattern, you
can run them with
$ mytool some/file.cc -- <compile command line args go here>

That said, cmake+ninja gives you a faster build (and an even faster
parallel build), so I personally always prefer to build with cmake+ninja
over configure+make.

Cheers,
/Manuel