Skip to content
Snippets Groups Projects
Commit 290a1836 authored by vepadulano's avatar vepadulano Committed by Axel Naumann
Browse files

Add INSTALL_RPATH to xrootd build and post install script to correct it after installation

parent c7152110
No related branches found
No related tags found
No related merge requests found
......@@ -906,6 +906,7 @@ if(builtin_xrootd)
-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
-DENABLE_PYTHON=OFF
-DENABLE_CEPH=OFF
-DCMAKE_INSTALL_RPATH:STRING=${XROOTD_ROOTDIR}/${XROOTD_LIBDIR}
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install
COMMAND ${CMAKE_COMMAND} -E copy_directory <INSTALL_DIR>/include/xrootd <INSTALL_DIR>/include
LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1
......@@ -918,6 +919,16 @@ if(builtin_xrootd)
set(XROOTD_CFLAGS "-DROOTXRDVERS=${XROOTD_VERSIONNUM}")
install(DIRECTORY ${XROOTD_ROOTDIR}/${XROOTD_LIBDIR}/ DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries FILES_MATCHING PATTERN "libXrd*")
install(DIRECTORY ${XROOTD_ROOTDIR}/include/xrootd/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT headers)
if(APPLE)
# XRootD libraries on mac need the LC_RPATH variable set. The build process already takes care of setting
# * BUILD_RPATH = build/XROOTD-prefix/../src
# * INSTALL_RPATH = build/lib
# Since the install directory for the builtin_xrootd target corresponds to the build directory of the main project.
# Use a post install script to change the LC_RPATH variable of the libraries in the ROOT install folder.
install(SCRIPT ${CMAKE_CURRENT_LIST_DIR}/XROOTDApplePostInstall.cmake
CODE "xrootd_libs_change_rpath(${XROOTD_ROOTDIR}/${XROOTD_LIBDIR} ${CMAKE_INSTALL_FULL_LIBDIR})"
)
endif()
set(XROOTD_TARGET XROOTD)
set(xrootd ON CACHE BOOL "Enabled because builtin_xrootd requested (${xrootd_description})" FORCE)
endif()
......
# Post install routine needed to change the LC_RPATH variable of the XRootD
# libraries on macOS after installation. The function changes the value from
# ${build_libdir} to ${install_libdir} with the `install_name_tool` executable.
# On successive reiterations of the `cmake --install` command,
# `install_name_tool` would error out since LC_RPATH would be already set to
# ${install_libdir}. Since that is what we want in the end, we redirect the
# errors to /dev/null.
function(xrootd_libs_change_rpath build_libdir install_libdir)
file(GLOB XROOTD_ALL_LIBRARIES
"${install_libdir}/libXrd*"
)
find_program(INSTALL_NAME_TOOL install_name_tool)
if(INSTALL_NAME_TOOL)
message(STATUS "Found tool ${INSTALL_NAME_TOOL}")
message(STATUS "Adjusting LC_RPATH variable of XRootD libraries in ${install_libdir}")
foreach(XRD_LIB_PATH ${XROOTD_ALL_LIBRARIES})
execute_process(COMMAND
bash -c "${INSTALL_NAME_TOOL} -rpath ${build_libdir} ${install_libdir} ${XRD_LIB_PATH} 2> /dev/null || true"
)
endforeach()
endif()
endfunction()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment