RFC: Move cmake shared files

The cmake files generated when building LLVM (including LLVMConfig.cmake) are to support cmake’s find_package() [1] function.

In the build dir the generated files are placed in /share/llvm/cmake. After install, in /lib/llvm/share/llvm/cmake.

CMake is not able to find them without a hint. CMake searches these paths on Unix:

  • /lib/llvm/cmake
  • /share/llvm/cmake

Some distributions try to workaround the problem by moving contents of /lib/llvm/share/llvm/cmake to /share/llvm/cmake, but usually that breaks the configuration included in LLVMConfig.cmake because of some hardcoded paths there.

I propose to move the generated files to /cmake and install them to /lib/llvm/cmake.

This should also help on Windows, where CMake searches in /llvm/cmake.

  • Paweł

[1] https://cmake.org/cmake/help/v3.0/command/find_package.html

In the build dir the generated files are placed in /share/llvm/cmake. After install, in /lib/llvm/share/llvm/cmake.

Really? According to this commit

In the build dir the generated files are placed in /share/llvm/cmake. After install, in /lib/llvm/share/llvm/cmake.

Really? According to this commit


r259821 | olesalscheider | 2016-02-04 20:08:19 +0000 (Thu, 04 Feb 2016) | 8 lines

Install cmake files to lib/cmake/llvm

This is the right location for platform-specific files.

On some distributions (e. g. Exherbo), a package can be installed for several

architectures in parallel, but the architecture-independent files are shared.

Therefore, we must not install architecture-dependent files (like the CMake

config and export files) to share/.


They’re built to /lib/cmake/llvm and installed to /lib/cmake/llvm, which matches

/(lib/|lib|share)/cmake/*/ (U)

in the cmake documentation you’ve linked.

(Note: this is trunk, I haven’t looked at 3.x or 4.0)

This is good news. But is this layout suitable to support multiple versions of LLVM?

Libs are installed to /lib, but packages changes that to /lib/llvm-X.Y. Should the packaging change also /lib/cmake/llvm to <prefix/lib/cmake/llvm-X.Y. If yes, this might cause the same issues with hardcoded/incorrectly assumed paths as I’m having now.