Skip to content

Commit fbec790

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 fbec790

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,9 @@ if (builtin_clang)
408408
else()
409409
find_package(Clang REQUIRED CONFIG)
410410
message(STATUS "Found Clang ${CLANG_PACKAGE_VERSION} in ${CLANG_CMAKE_DIR}")
411+
412+
# Forward CLANG_INSTALL_PREFIX so it can be used by core/clingutils/CMakeLists.txt
413+
set(CLANG_INSTALL_PREFIX ${CLANG_INSTALL_PREFIX} PARENT_SCOPE)
411414
endif()
412415

413416
# Reset the compiler flags after compiling LLVM and Clang

0 commit comments

Comments
 (0)