Skip to content

[CMake] Update builtin_cling=OFF configuration code #18598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions core/metacling/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,6 @@ add_dependencies(MetaCling CLING clangCppInterOp)

##### libCling #############################################################

if(NOT builtin_clang)
set(prefixed_link_libraries)
foreach(dep ${CLING_DEPEND_LIBS})
if("${dep}" MATCHES "^clang")
set(dep "${LLVM_LIBRARY_DIR}/lib${dep}.a")
endif()
list(APPEND prefixed_link_libraries "${dep}")
endforeach()
set(LINK_LIBS "${prefixed_link_libraries}")
link_directories("${LLVM_LIBRARY_DIR}")
endif()

# We need to paste the content of the cling plugins disabling link symbol optimizations.
set(CLING_PLUGIN_LINK_LIBS)
if (clad)
Expand Down
1 change: 0 additions & 1 deletion core/rootcling_stage1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ endif()
if(builtin_clang)
set(CLING_LIBRARIES "clingMetaProcessor")
else()
list(APPEND CLING_LIBRARIES ${CLING_DEPEND_LIBS})
link_directories("${LLVM_LIBRARY_DIR}")
endif()

Expand Down
49 changes: 13 additions & 36 deletions interpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -471,42 +471,19 @@ if (builtin_cling)
endif()
endif()
else()
set(Cling_DIR ${LLVM_BINARY_DIR}/lib/cmake/cling/)
find_package(Cling REQUIRED CONFIG PATHS ${Cling_DIR} "${Cling_DIR}/lib/cmake/cling" "${Cling_DIR}/cmake" NO_DEFAULT_PATH)
find_package(Clang REQUIRED CONFIG PATHS ${Cling_DIR} "${Cling_DIR}/lib/cmake/clang" "${Cling_DIR}/cmake" NO_DEFAULT_PATH)

# We need to consider not just the direct link dependencies, but also the
# transitive link dependencies. Do this by starting with the set of direct
# dependencies, then the dependencies of those dependencies, and so on.
set(new_libs "clingMetaProcessor")
set(link_libs ${new_libs})
while(NOT "${new_libs}" STREQUAL "")
foreach(lib ${new_libs})
if(TARGET ${lib})
get_target_property(lib_type ${lib} TYPE)
if("${lib_type}" STREQUAL "STATIC_LIBRARY")
list(APPEND static_libs ${lib})
else()
list(APPEND other_libs ${lib})
endif()
get_target_property(transitive_libs ${lib} INTERFACE_LINK_LIBRARIES)
if (NOT transitive_libs)
continue()
endif()
foreach(transitive_lib ${transitive_libs})
list(FIND link_libs ${transitive_lib} idx)
#if(TARGET ${transitive_lib} AND idx EQUAL -1)
if(idx EQUAL -1)
list(APPEND newer_libs ${transitive_lib})
list(APPEND link_libs ${transitive_lib})
endif()
endforeach(transitive_lib)
endif()
endforeach(lib)
set(new_libs ${newer_libs})
set(newer_libs "")
endwhile()
set(CLING_DEPEND_LIBS ${link_libs} CACHE STRING "")
# We're using the GLOBAL argument to find_package(Cling) to make the
# imported targets available everywhere. This feature was only introduced
# with CMake 3.24, so we error out if the version is lower.
# TODO: remove once minimum CMake version required for ROOT is >= 3.24.
if(CMAKE_VERSION VERSION_LESS 3.24.0)
message(FATAL_ERROR "Building ROOT with builtin_cling=OFF requires at least CMake 3.24.0 (current CMake version is ${CMAKE_VERSION})")
endif()

find_package(Cling REQUIRED CONFIG GLOBAL)
find_package(Clang REQUIRED CONFIG)

# Forward CLING_INCLUDE_DIRS so it can be used outside the interpreter subdirectory
set(CLING_INCLUDE_DIRS ${CLING_INCLUDE_DIRS} PARENT_SCOPE)
endif(builtin_cling)


Expand Down
Loading