diff --git a/interpreter/CMakeLists.txt b/interpreter/CMakeLists.txt index 77d5d7f01355d..ed7242cf3f527 100644 --- a/interpreter/CMakeLists.txt +++ b/interpreter/CMakeLists.txt @@ -393,14 +393,29 @@ else() # Disable linking against shared LLVM set(LLVM_LINK_LLVM_DYLIB OFF) + # To ensure this override stays constant, we need to avoid subdirectories calling find_package(LLVM), + # which would set it to ON again if system was compiled that way + # Define a macro with a toggle flag to override find_package, that will only be visible in this scope, not in parent one. + # TEMPORARY: remove this workaround once ROOT can link against the shared + # libLLVM.so for builtin_llvm=OFF + macro(find_package _package_name) + if(ROOT_SKIP_FIND_LLVM_WITHIN_CLANG AND "${_package_name}" STREQUAL "LLVM") + message(STATUS "[ROOT] Suppressed find_package(LLVM) at ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE}" + " to keep LLVM_LINK_LLVM_DYLIB=OFF.") + else() + _find_package(${_package_name} ${ARGN}) + endif() + endmacro() # Always build LLVM with C++17. It is not necessary to compile with the same # C++ standard as the rest of ROOT and sometimes it doesn't even work. set(_cxx_standard ${CMAKE_CXX_STANDARD}) set(CMAKE_CXX_STANDARD 17) + set(ROOT_SKIP_FIND_LLVM_WITHIN_CLANG ON) add_subdirectory(llvm-project/clang EXCLUDE_FROM_ALL) - + set(ROOT_SKIP_FIND_LLVM_WITHIN_CLANG OFF) + set(CMAKE_CXX_STANDARD ${_cxx_standard}) endif(builtin_clang)