Search code examples
installationcmakeclangllvmninja

When you build llvm from source, how do you install it to your system?


When reading through this:

https://www.llvm.org/docs/CMake.html

It tells you how to install to a target, but it doesn't tell you how to install to the system.

cmake --build . --target install

I am not sure what the target is in this case, nor how to properly configure it so it appears as a standard installation into my ubuntu system, insofar as it would be functionally the same as if I installed the development debian packages, and have it picked up by any other build looking to see if the libraries are installed.

Hence, how do I install all the projects under the llvm suite, from source, into Linux?


Solution

  • That command will install LLVM and all the configured projects (via LLVM_ENABLE_PROJECTS) to whatever location you specified in the first step with the CMAKE_INSTALL_PREFIX variable.

    If you did not set it, it takes on a platform-dependent value, most likely /usr/local on Linux. This is an appropriate place to put it. I would discourage you from trespassing on the package manager's territory. Untold misery is likely to result.

    A "target" in CMake (and many other build systems) is just "something that must be done". Usually it's "compile something to a file with a corresponding name", but it can also be "run an installation script". CMake creates an install target for that purpose in every project. It's also a popular convention in Make/autotools based build systems.