From 7da9bf8ade7e9cb24a3d61aaa6dc59f28bd12d6d Mon Sep 17 00:00:00 2001 From: Valentin Volkl <valentin.volkl@cern.ch> Date: Mon, 8 May 2023 15:55:50 +0200 Subject: [PATCH] reformat and add comments --- CMakeLists.txt | 32 ++++---------------------------- Gaudi/python/Gaudi/__init__.py | 10 ++++++---- cmake/GaudiRPath.cmake | 28 ++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 32 deletions(-) create mode 100644 cmake/GaudiRPath.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 6448c9848..5607d50d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,34 +88,10 @@ project(Gaudi VERSION 36.12 # Add the "Developer" build type include(cmake/DeveloperBuildType.cmake) - - -set(CMAKE_SKIP_BUILD_RPATH FALSE) # don't skip the full RPATH for the build tree - set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # use always the build RPATH for the build tree - set(CMAKE_MACOSX_RPATH TRUE) # use RPATH for MacOSX - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # point to directories outside the build tree to the install RPATH - - # Check whether to add RPATH to the installation (the build tree always has the RPATH enabled) - if(APPLE) - set(CMAKE_INSTALL_NAME_DIR "@rpath") - set(CMAKE_INSTALL_RPATH "@loader_path/../lib") # self relative LIBDIR - # the RPATH to be used when installing, but only if it's not a system directory - list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) - if("${isSystemDir}" STREQUAL "-1") - set(CMAKE_INSTALL_RPATH "@loader_path/../lib") - endif("${isSystemDir}" STREQUAL "-1") - elseif(DD4HEP_SET_RPATH) - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") # install LIBDIR - # the RPATH to be used when installing, but only if it's not a system directory - list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) - if("${isSystemDir}" STREQUAL "-1") - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") - endif("${isSystemDir}" STREQUAL "-1") - else() - set(CMAKE_SKIP_INSTALL_RPATH TRUE) # skip the full RPATH for the install tree - endif() - - +# set RPATH (currently only on macOS) +if(APPLE) + include(cmake/GaudiRPath.cmake) +endif() # Set up the GAUDI_ATOMIC_LIBS variable include(cmake/GaudiAtomicLibs.cmake) diff --git a/Gaudi/python/Gaudi/__init__.py b/Gaudi/python/Gaudi/__init__.py index cf9a350c2..32029b8ec 100644 --- a/Gaudi/python/Gaudi/__init__.py +++ b/Gaudi/python/Gaudi/__init__.py @@ -92,10 +92,12 @@ class Application(object): # API must be protected acquiring the GIL # if sys.platform == "darwin": - libpaths = os.environ["GAUDI_LIBRARY_PATH"] - if not libpaths: - print("ERROR: GAUDI_LIBRARY_PATH is empty!") - for _path in libpaths.split(':'): + # LD_LIBRARY_PATH cannot be used for dlopen on macos; + # use custom variable GAUDI_LIBRARY_PATH instead + _libpaths = os.environ["GAUDI_LIBRARY_PATH"] + if not _libpaths: + print("WARNING: GAUDI_LIBRARY_PATH is empty!") + for _path in _libpaths.split(':'): _lib = os.path.join(_path, "libGaudiKernel.dylib") if os.path.isfile(_lib): gkl = _GaudiKernelLib = ctypes.CDLL( diff --git a/cmake/GaudiRPath.cmake b/cmake/GaudiRPath.cmake new file mode 100644 index 000000000..e57aff6e6 --- /dev/null +++ b/cmake/GaudiRPath.cmake @@ -0,0 +1,28 @@ +# This file sets up Gaudi to fill the RPATH for its libraries. +# It is inspired from DD4hep (https://github.com/AIDASoft/DD4hep/blob/master/cmake/DD4hepBuild.cmake) + + +set(CMAKE_SKIP_BUILD_RPATH FALSE) # don't skip the full RPATH for the build tree +set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # use always the build RPATH for the build tree +set(CMAKE_MACOSX_RPATH TRUE) # use RPATH for MacOSX +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # point to directories outside the build tree to the install RPATH + +# Check whether to add RPATH to the installation (the build tree always has the RPATH enabled) +if(APPLE) + set(CMAKE_INSTALL_NAME_DIR "@rpath") + set(CMAKE_INSTALL_RPATH "@loader_path/../lib") # self relative LIBDIR + # the RPATH to be used when installing, but only if it's not a system directory + list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) + if("${isSystemDir}" STREQUAL "-1") + set(CMAKE_INSTALL_RPATH "@loader_path/../lib") + endif("${isSystemDir}" STREQUAL "-1") +elseif(DD4HEP_SET_RPATH) + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") # install LIBDIR + # the RPATH to be used when installing, but only if it's not a system directory + list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) + if("${isSystemDir}" STREQUAL "-1") + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + endif("${isSystemDir}" STREQUAL "-1") +else() + set(CMAKE_SKIP_INSTALL_RPATH TRUE) # skip the full RPATH for the install tree +endif() -- GitLab