Skip to content

Commit 1f71e8b

Browse files
committed
[CMake] Get Clang directory from CLANG_INSTALL_PREFIX
If Clang was installed standalone (in particular, not in the LLVM tree), use the CLANG_INSTALL_PREFIX variable to indicate where it is. Actually, we can always use `CLANG_INSTALL_PREFIX`. It's defined by `ClangConfig.cmake`. To make sure that this works, `find_package(Clang)` has to be called in `core/clingutils/CMakeLists.txt`.
1 parent ccfe078 commit 1f71e8b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

core/clingutils/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,14 @@ if (builtin_clang)
8585
set(CLANG_RESOURCE_DIR_STEM ${CMAKE_BINARY_DIR}/interpreter/llvm-project/llvm/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}/clang)
8686
set(CLANG_RESOURCE_DIR_VERSION ${LLVM_VERSION_MAJOR})
8787
else ()
88-
set(CLANG_RESOURCE_DIR_STEM ${LLVM_LIBRARY_DIR}/clang)
88+
89+
# We also do find_package(Clang) in the interpreter directory, but since this
90+
# CMakeLists file is not part of that dir we need to find Clang also here.
91+
# Otherwise, the CLANG_INSTALL_PREFIX variable won't be set.
92+
find_package(Clang REQUIRED CONFIG)
93+
94+
set(CLANG_RESOURCE_DIR_STEM ${CLANG_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}/clang)
95+
8996
# A user can define a clang version to use, otherwise find it (but will error if more than one version is present)
9097
if (NOT DEFINED CLANG_RESOURCE_DIR_VERSION)
9198
if (NOT EXISTS ${CLANG_RESOURCE_DIR_STEM})

0 commit comments

Comments
 (0)