Skip to content

Commit 66f562d

Browse files
[cmake] Improve interface for external LLVM
1 parent 7ad062b commit 66f562d

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

interpreter/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ else()
343343
if (${PACKAGE_VERSION} MATCHES "${ROOT_LLVM_VERSION_REQUIRED_MAJOR}\\.0(|\\.[0-9]+)")
344344
message(STATUS "Using LLVM external library - ${PACKAGE_VERSION}")
345345
else()
346-
message(FATAL_ERROR "LLVM version different from ROOT supported, please try ${ROOT_LLVM_VERSION_REQUIRED_MAJOR}.0.x")
346+
message(FATAL_ERROR "LLVM version ${LLVM_PACKAGE_VERSION} different from ROOT supported, please try ${ROOT_LLVM_VERSION_REQUIRED_MAJOR}.0.x")
347347
endif()
348348

349349
if (NOT DEFINED LLVM_INCLUDE_TESTS)
@@ -503,6 +503,7 @@ if (builtin_cling)
503503
string(APPEND CMAKE_C_FLAGS " -fPIC")
504504
endif(LLVM_ENABLE_PIC AND NOT MSVC)
505505
# Avoid cling being installed under ROOTSYS/include.
506+
set(CLING_ROOT_BUILD ON)
506507
add_subdirectory(cling EXCLUDE_FROM_ALL)
507508
add_dependencies(CLING ${CLING_LIBRARIES})
508509

interpreter/cling/CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ Please install Python or specify the PYTHON_EXECUTABLE CMake variable.")
167167

168168
set( CLING_BUILT_STANDALONE 1 )
169169
set(BACKEND_PACKAGE_STRING "LLVM ${LLVM_PACKAGE_VERSION}")
170-
else() # Building as part of LLVM
170+
elseif(DEFINED CLING_ROOT_BUILD)
171+
message(STATUS "Building Cling as part of ROOT")
172+
# we do not need to include LLVMConfig again, already done
173+
else()
174+
message(STATUS "Building Cling as part of LLVM")
171175
set(BACKEND_PACKAGE_STRING "${PACKAGE_STRING}")
172176
# Try finding the LLVMConfig.cmake if we build against prebuilt LLVM
173177
set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
@@ -195,7 +199,7 @@ endif()
195199
set(CLING_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
196200
set(CLING_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
197201
set(LLVM_TOOLS_BINARY_DIR "${LLVM_BINARY_DIR}/bin")
198-
if(DEFINED ROOT_BINARY_DIR)
202+
if(DEFINED CLING_ROOT_BUILD)
199203
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${LLVM_TOOLS_BINARY_DIR}")
200204
endif()
201205

@@ -295,7 +299,7 @@ endif ()
295299
# The package needs to be compiler without RTTI information
296300
if(MSVC)
297301
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -GR-")
298-
if(NOT DEFINED ROOT_BINARY_DIR)
302+
if(NOT DEFINED CLING_ROOT_BUILD)
299303
# Add the /std:c++XX flag for Visual Studio if not building as part of ROOT
300304
if(MSVC_VERSION GREATER_EQUAL 1920)
301305
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std:c++17")
@@ -327,7 +331,7 @@ file (STRINGS "VERSION" CLING_VERSION)
327331
string(REGEX REPLACE "([0-9]).[0-9]+~[a-zA-Z]+" "\\1" CLING_VERSION_MAJOR ${CLING_VERSION})
328332
string(REGEX REPLACE "[0-9].([0-9]+)~[a-zA-Z]+" "\\1" CLING_VERSION_MINOR ${CLING_VERSION})
329333

330-
if(DEFINED ROOT_BINARY_DIR)
334+
if(DEFINED CLING_ROOT_BUILD)
331335
# Building as part of ROOT; visibility is "inherited" from ROOT/interpreter.
332336
set(CLING_VERSION ROOT_${CLING_VERSION})
333337
else()

0 commit comments

Comments
 (0)