Skip to content

Commit 6b4a4f1

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 6b4a4f1

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

core/clingutils/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ 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+
set(CLANG_RESOURCE_DIR_STEM ${CLANG_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}/clang)
8989
# A user can define a clang version to use, otherwise find it (but will error if more than one version is present)
9090
if (NOT DEFINED CLANG_RESOURCE_DIR_VERSION)
9191
if (NOT EXISTS ${CLANG_RESOURCE_DIR_STEM})

interpreter/CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ set(LLVM_FORCE_USE_OLD_TOOLCHAIN ON CACHE BOOL "")
5555
# (Note that the option is very counter-intuitive: We turn *on* disabling it...)
5656
set(CMAKE_DISABLE_FIND_PACKAGE_CUDA ON)
5757

58-
# will be set again in case NOT builtin_llvm
59-
set(LLVM_DIR "${CMAKE_CURRENT_BINARY_DIR}/llvm-project/llvm")
58+
if(builtin_llvm)
59+
set(LLVM_DIR "${CMAKE_CURRENT_BINARY_DIR}/llvm-project/llvm")
60+
endif()
61+
6062
if (clad)
6163
set(CLING_BUILD_PLUGINS ON)
6264
endif()
@@ -408,6 +410,9 @@ if (builtin_clang)
408410
else()
409411
find_package(Clang REQUIRED CONFIG)
410412
message(STATUS "Found Clang ${CLANG_PACKAGE_VERSION} in ${CLANG_CMAKE_DIR}")
413+
414+
# Forward CLANG_INSTALL_PREFIX so it can be used by core/clingutils/CMakeLists.txt
415+
set(CLANG_INSTALL_PREFIX ${CLANG_INSTALL_PREFIX} PARENT_SCOPE)
411416
endif()
412417

413418
# Reset the compiler flags after compiling LLVM and Clang

0 commit comments

Comments
 (0)