This is an archive of the discontinued LLVM Phabricator instance.

[cmake] Hint find_package() to prefer LLVM installed alongside clang
ClosedPublic

Authored by mgorny on Jan 30 2017, 1:55 PM.

Details

Summary

Include a path hint for find_package() in ClangConfig.cmake to ensure
that CMake prefers LLVM installed alongside clang over the default
search path.

If two versions of LLVM are installed in the system, and one of them is
in PATH, CMake's find_package() magic prefers the CMake directory
alongside that install by default. Adding a relative hint makes it
possible to prioritize to the install from which find_package() is
called.

If you want to build e.g. LLDB against another install of LLVM, you can
pass LLVM_CONFIG override. In this case, LLDB queries the prefix from
llvm-config and uses the CMake files located there. However, when
including ClangConfig, the implicit find_package() nevertheless prefers
PATH-found LLVM over the one used previously by LLDB, and two versions
of LLVMConfig end up being loaded.

This could be fixed on LLDB end up by explicitly forcing custom package
search location. However, it seems simpler and safer to add a hint to
ClangConfig than to track every usage of ClangConfig.

Diff Detail

Repository
rL LLVM

Event Timeline

mgorny created this revision.Jan 30 2017, 1:55 PM
rnk accepted this revision.Jan 30 2017, 6:00 PM

lgtm

This revision is now accepted and ready to land.Jan 30 2017, 6:00 PM
This revision was automatically updated to reflect the committed changes.