From b31259bda00b4f80d88f0e67ef19edf488b7cc0e Mon Sep 17 00:00:00 2001 From: Stephan Hageboeck Date: Fri, 26 Sep 2025 19:09:05 +0200 Subject: [PATCH] [Core] Set a BUILD_RPATH for libCore. Usually, CMake automatically sets RUNPATH when target_link_libraries is used. However, since Core doesn't have other ROOT dependencies, its RUNPATH might only contain external dependencies or remain empty. To enable Core to find other ROOT libraries, its current location is added to its BUILD_RPATH. --- core/CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 02b683ce89817..57a5284ef7e77 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -26,6 +26,14 @@ add_custom_target(rconfigure ALL DEPENDS ${CMAKE_BINARY_DIR}/include/RConfigure. ROOT_LINKER_LIBRARY(Core BUILTINS LZMA) +# This sets RUNPATH for libCore, which enables it to dlopen any ROOT library in its directory. +# If omitted, Core might try to load libraries from a ROOT that's installed in the system. +if(APPLE) + set_property(TARGET Core APPEND PROPERTY BUILD_RPATH @loader_path) +elseif(NOT WIN32) + set_property(TARGET Core APPEND PROPERTY BUILD_RPATH $ORIGIN) +endif() + generateHeader(Core ${CMAKE_SOURCE_DIR}/core/base/src/root-argparse.py ${CMAKE_BINARY_DIR}/ginclude/TApplicationCommandLineOptionsHelp.h