Skip to content
Snippets Groups Projects
Commit 2ce371e4 authored by Marko Petric's avatar Marko Petric
Browse files

Update RPATH settings

parent d3159ed5
No related branches found
No related tags found
No related merge requests found
...@@ -75,7 +75,8 @@ option(DD4HEP_USE_HEPMC3 "Build hepmc3 extensions" OFF) ...@@ -75,7 +75,8 @@ option(DD4HEP_USE_HEPMC3 "Build hepmc3 extensions" OFF)
option(DD4HEP_LOAD_ASSIMP "Download and build ASSIMP from github" OFF) option(DD4HEP_LOAD_ASSIMP "Download and build ASSIMP from github" OFF)
option(BUILD_TESTING "Enable and build tests" ON) option(BUILD_TESTING "Enable and build tests" ON)
option(BUILD_SHARED_LIBS "If OFF build STATIC Libraries" ON) option(BUILD_SHARED_LIBS "If OFF build STATIC Libraries" ON)
option(CMAKE_MACOSX_RPATH "Build with rpath on macos" ON) option(DD4HEP_SET_RPATH "Link libraries with built-in RPATH (run-time search path)" ON)
SET(DD4HEP_BUILD_PACKAGES "DDRec DDDetectors DDCond DDAlign DDCAD DDDigi DDG4 DDEve UtilityApps" SET(DD4HEP_BUILD_PACKAGES "DDRec DDDetectors DDCond DDAlign DDCAD DDDigi DDG4 DDEve UtilityApps"
CACHE STRING "List of DD4hep packages to build") CACHE STRING "List of DD4hep packages to build")
SEPARATE_ARGUMENTS(DD4HEP_BUILD_PACKAGES) SEPARATE_ARGUMENTS(DD4HEP_BUILD_PACKAGES)
...@@ -206,14 +207,6 @@ endif() ...@@ -206,14 +207,6 @@ endif()
ENDIF(DD4HEP_USE_EXISTING_DD4HEP) ENDIF(DD4HEP_USE_EXISTING_DD4HEP)
#######################
# Treatment for Apple #
#######################
if( APPLE )
set( USE_DYLD 1)
set(CMAKE_MACOSX_RPATH 1)
endif()
######################### #########################
# Configure and install # # Configure and install #
......
...@@ -88,26 +88,31 @@ macro(dd4hep_set_compiler_flags) ...@@ -88,26 +88,31 @@ macro(dd4hep_set_compiler_flags)
MESSAGE( WARNING "We do not test with the ${CMAKE_CXX_COMPILER_ID} compiler, use at your own discretion" ) MESSAGE( WARNING "We do not test with the ${CMAKE_CXX_COMPILER_ID} compiler, use at your own discretion" )
endif() endif()
#rpath treatment #---RPATH options-------------------------------------------------------------------------------
# When building, don't use the install RPATH already (but later on when installing)
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) if(APPLE)
# use, i.e. don't skip the full RPATH for the build tree set(CMAKE_INSTALL_NAME_DIR "@rpath")
SET(CMAKE_SKIP_BUILD_RPATH FALSE) 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
# when building, don't use the install RPATH already list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
# (but later on when installing) if("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) set(CMAKE_INSTALL_RPATH "@loader_path/../lib")
endif("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") elseif(DD4HEP_SET_RPATH)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") # install LIBDIR
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing, but only if it's not a system directory # 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) list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1") if("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
ENDIF("${isSystemDir}" STREQUAL "-1") endif("${isSystemDir}" STREQUAL "-1")
else()
set(CMAKE_SKIP_INSTALL_RPATH TRUE) # skip the full RPATH for the install tree
endif() endif()
endmacro(dd4hep_set_compiler_flags) endmacro(dd4hep_set_compiler_flags)
...@@ -561,7 +566,7 @@ function(dd4hep_add_dictionary dictionary ) ...@@ -561,7 +566,7 @@ function(dd4hep_add_dictionary dictionary )
add_custom_command(OUTPUT ${dictionary}.cxx ${output_dir}/${dictionary}_rdict.pcm add_custom_command(OUTPUT ${dictionary}.cxx ${output_dir}/${dictionary}_rdict.pcm
COMMAND ${ROOT_rootcling_CMD} COMMAND ${ROOT_rootcling_CMD}
ARGS -f ${dictionary}.cxx -s ${output_dir}/${dictionary} -inlineInputHeader ARGS -f ${dictionary}.cxx -s ${output_dir}/${dictionary} -inlineInputHeader
${ARG_OPTIONS} -std=c++${CMAKE_CXX_STANDARD} ${ARG_OPTIONS}
"$<$<BOOL:$<JOIN:${comp_defs},>>:-D$<JOIN:${comp_defs},;-D>>" "$<$<BOOL:$<JOIN:${comp_defs},>>:-D$<JOIN:${comp_defs},;-D>>"
"$<$<BOOL:$<JOIN:${inc_dirs},>>:-I$<JOIN:${inc_dirs},;-I>>" "$<$<BOOL:$<JOIN:${inc_dirs},>>:-I$<JOIN:${inc_dirs},;-I>>"
"$<JOIN:${headers},;>" "$<JOIN:${linkdefs},;>" "$<JOIN:${headers},;>" "$<JOIN:${linkdefs},;>"
......
...@@ -3,6 +3,11 @@ IF($ENV{VERBOSE}) ...@@ -3,6 +3,11 @@ IF($ENV{VERBOSE})
MESSAGE(" *** MakeGaudiMap.cmake run command : ${DD4HEP_LISTCOMPONENTS_CMD} -o ${rootmapfile} ${libname} MESSAGE(" *** MakeGaudiMap.cmake run command : ${DD4HEP_LISTCOMPONENTS_CMD} -o ${rootmapfile} ${libname}
WORKING_DIRECTORY ${LIBRARY_LOCATION} " WORKING_DIRECTORY ${LIBRARY_LOCATION} "
) )
MESSAGE("DD4HEP_LIBRARY_LOCATION = ${DD4HEP_LIBRARY_LOCATION}")
MESSAGE("DYLD_LIBRARY_PATH = $ENV{DYLD_LIBRARY_PATH}")
MESSAGE("DD4HEP_LIBRARY_PATH = $ENV{DD4HEP_LIBRARY_PATH}")
MESSAGE("LD_LIBRARY_PATH = $ENV{LD_LIBRARY_PATH}")
MESSAGE("LIBRARY_LOCATION = ${LIBRARY_LOCATION}")
ENDIF() ENDIF()
GET_FILENAME_COMPONENT(GAUDI_LISTCOMP_INSTALL ${DD4HEP_LISTCOMPONENTS_CMD} DIRECTORY) GET_FILENAME_COMPONENT(GAUDI_LISTCOMP_INSTALL ${DD4HEP_LISTCOMPONENTS_CMD} DIRECTORY)
...@@ -11,7 +16,7 @@ ENDIF() ...@@ -11,7 +16,7 @@ ENDIF()
else() else()
SET ( ENV{LD_LIBRARY_PATH} ${LIBRARY_LOCATION}:${DD4HEP_LIBRARY_LOCATION}:$ENV{LD_LIBRARY_PATH} ) SET ( ENV{LD_LIBRARY_PATH} ${LIBRARY_LOCATION}:${DD4HEP_LIBRARY_LOCATION}:$ENV{LD_LIBRARY_PATH} )
endif() endif()
# EXECUTE_PROCESS( COMMAND echo LD_LIBRARY_PATH = $ENV{LD_LIBRARY_PATH} )
EXECUTE_PROCESS( COMMAND EXECUTE_PROCESS( COMMAND
${DD4HEP_LISTCOMPONENTS_CMD} -o ${rootmapfile} ${libname} ${DD4HEP_LISTCOMPONENTS_CMD} -o ${rootmapfile} ${libname}
WORKING_DIRECTORY ${LIBRARY_LOCATION} WORKING_DIRECTORY ${LIBRARY_LOCATION}
......
...@@ -21,7 +21,9 @@ for i in "$@" ; do ...@@ -21,7 +21,9 @@ for i in "$@" ; do
fi fi
done done
export DYLD_LIBRARY_PATH=$DD4HEP_LIBRARY_PATH
echo " #### LD_LIBRARY_PATH = : ${LD_LIBRARY_PATH}" echo " #### LD_LIBRARY_PATH = : ${LD_LIBRARY_PATH}"
echo " #### DYLD_LIBRARY_PATH = : ${DYLD_LIBRARY_PATH}"
echo "---running test : '" ${command} ${theargs} "'" echo "---running test : '" ${command} ${theargs} "'"
eval ${command} ${theargs} eval ${command} ${theargs}
...@@ -20,7 +20,9 @@ for i in "$@" ; do ...@@ -20,7 +20,9 @@ for i in "$@" ; do
fi fi
done done
export DYLD_LIBRARY_PATH=$DD4HEP_LIBRARY_PATH
echo " #### LD_LIBRARY_PATH = : ${LD_LIBRARY_PATH}" echo " #### LD_LIBRARY_PATH = : ${LD_LIBRARY_PATH}"
echo " #### DYLD_LIBRARY_PATH = : ${DYLD_LIBRARY_PATH}"
echo " ### running test : '${command} ${theargs}'" echo " ### running test : '${command} ${theargs}'"
exec ${command} ${theargs} exec ${command} ${theargs}
...@@ -10,21 +10,22 @@ ...@@ -10,21 +10,22 @@
# #
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
dd4hep_parse_this() { dd4hep_parse_this() {
package=${2}; SOURCE=${1}
if [ "x${1}" = "x" ]; then if [ "x${SOURCE}" = "x" ]; then
if [ ! -f bin/this${package}.sh ]; then if [ -f bin/thisdd4hep.sh ]; then
echo ERROR: must "cd where/${package}/is" before calling ". bin/this${package}.sh" for this version of bash!; THIS="$PWD"; export THIS
return 1; elif [ -f ./thisdd4hep.sh ]; then
THIS=$(cd .. > /dev/null; pwd); export THIS
else
echo ERROR: must "cd where/dd4hep/is" before calling ". bin/thisdd4hep.sh" for this version of bash!
THIS=; export THIS
return 1
fi fi
THIS="${PWD}";
else else
# get param to "." # get param to "."
THIS=$(dirname $(dirname ${1})); thisroot=$(dirname ${SOURCE})
#if [ ! -f ${THIS}/bin/this${package}.sh ]; then THIS=$(cd ${thisroot}/.. > /dev/null;pwd); export THIS
# THIS=$(dirname ${package}); fi
#fi;
fi;
THIS=$(cd ${THIS} > /dev/null; pwd);
} }
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
dd4hep_add_path() { dd4hep_add_path() {
...@@ -61,7 +62,12 @@ dd4hep_add_library_path() { ...@@ -61,7 +62,12 @@ dd4hep_add_library_path() {
} }
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# #
dd4hep_parse_this ${BASH_ARGV[0]} DD4hep; SOURCE=${BASH_ARGV[0]}
if [ "x$SOURCE" = "x" ]; then
SOURCE=${(%):-%N} # for zsh
fi
dd4hep_parse_this $SOURCE;
# #
# These 3 are the main configuration variables: ROOT, Geant4 and XercesC # These 3 are the main configuration variables: ROOT, Geant4 and XercesC
# --> LCIO & Co. are handled elsewhere! # --> LCIO & Co. are handled elsewhere!
......
...@@ -33,9 +33,12 @@ SET( ENV{DD4hepExamplesINSTALL} ${CMAKE_INSTALL_PREFIX} ) ...@@ -33,9 +33,12 @@ SET( ENV{DD4hepExamplesINSTALL} ${CMAKE_INSTALL_PREFIX} )
IF(NOT TARGET DD4hep::DDCore) IF(NOT TARGET DD4hep::DDCore)
find_package ( DD4hep REQUIRED ) find_package ( DD4hep REQUIRED )
ENDIF() ENDIF()
include(DD4hepMacros)
dd4hep_set_compiler_flags()
dd4hep_configure_output() dd4hep_configure_output()
#========================================================================== #==========================================================================
SET(DD4HEP_EXAMPLES "AlignDet CLICSiD ClientTests Conditions DDCMS DDCodex DDDB DDDigi DDG4 DDG4_MySensDet LHeD OpticalSurfaces Persistency DDCAD SimpleDetector" SET(DD4HEP_EXAMPLES "AlignDet CLICSiD ClientTests Conditions DDCMS DDCodex DDDB DDDigi DDG4 DDG4_MySensDet LHeD OpticalSurfaces Persistency DDCAD SimpleDetector"
...@@ -46,3 +49,19 @@ FOREACH(DDExample IN LISTS DD4HEP_EXAMPLES) ...@@ -46,3 +49,19 @@ FOREACH(DDExample IN LISTS DD4HEP_EXAMPLES)
dd4hep_print("|> Building ${DDExample}") dd4hep_print("|> Building ${DDExample}")
add_subdirectory(${DDExample}) add_subdirectory(${DDExample})
ENDFOREACH() ENDFOREACH()
if(APPLE)
SET ( ENV{DD4HEP_LIBRARY_PATH} $ENV{DYLD_LIBRARY_PATH} )
else()
SET ( ENV{DD4HEP_LIBRARY_PATH} ${LD_LIBRARY_PATH} )
SET ( DD4HEP_LIBRARY_PATH ${LD_LIBRARY_PATH} )
endif()
#######################
# Treatment for Apple #
#######################
if(APPLE)
fill_dd4hep_library_path()
message(STATUS "DD4HEP_LIBRARY_PATH= $ENV{DD4HEP_LIBRARY_PATH}")
endif()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment