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.
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.