If we only get LLVM_DIR and find Clang in the same provided build-tree, automatically infer Clang_DIR like this:
LLVM_DIR = /path/to/build-llvm/lib/cmake/llvm Clang_DIR = /paht/to/build-llvm/lib/cmake/clang
Differential D65798
[lldb][CMake] Infer `Clang_DIR` if not passed explicitly sgraenitz on Aug 6 2019, 3:34 AM. Authored by
Details If we only get LLVM_DIR and find Clang in the same provided build-tree, automatically infer Clang_DIR like this: LLVM_DIR = /path/to/build-llvm/lib/cmake/llvm Clang_DIR = /paht/to/build-llvm/lib/cmake/clang
Diff Detail
Event Timeline
Comment Actions Making it so that the clang is automatically found it if happens to be next to llvm seems like a reasonable thing to me. I have no idea what would be the canonical cmake way to do that... Comment Actions Update documentation to mention multiple provided build trees and the usage of Clang_DIR Comment Actions "the canonical cmake way" good question! It turns out that, providing another hint for find_package(Clang ...) does exactly that: it sets Clang_DIR to the first path where it found Clang. If we do not attach great importance to the status message, we could do: find_package(LLVM REQUIRED CONFIG HINTS ${LLVM_DIR} NO_CMAKE_FIND_ROOT_PATH) find_package(Clang REQUIRED CONFIG HINTS ${Clang_DIR} ${LLVM_DIR}/../clang NO_CMAKE_FIND_ROOT_PATH) # Clang_DIR is defined now even if the ${LLVM_DIR}/../clang fallback was used Comment Actions I'm happy with this, and it looks very nice and idiomatic, but maybe wait for @compnerd a bit, as he had some reservations about the whole thing.. |
What happens in the standalone clang build scenario? Can I ask what is the motivation for this change? I think it is better to require that the user pass the path, as that is an explicit dependency of LLDB.