diff --git a/src/other/ext/CMake/ExternalProject_Target.cmake b/src/other/ext/CMake/ExternalProject_Target.cmake index 918b5078862..7f634d08ecc 100644 --- a/src/other/ext/CMake/ExternalProject_Target.cmake +++ b/src/other/ext/CMake/ExternalProject_Target.cmake @@ -249,6 +249,7 @@ endfunction(ET_Origin_Path) # /usr/bin/baz -> bin/baz # /usr/bin/mypkg/baz -> bin/mypkg/baz # +find_program(CHRPATH_EXEC chrpath) function(ET_RPath OFILE) get_filename_component(OFPATH "${OFILE}" DIRECTORY) get_filename_component(RRPATH "${CMAKE_INSTALL_PREFIX}/${OFPATH}" REALPATH) @@ -272,7 +273,16 @@ function(ET_RPath OFILE) execute_process(COMMAND install_name_tool -delete_rpath \"${CMAKE_BUILD_RPATH}\" \"\${WPATH}\") execute_process(COMMAND install_name_tool -add_rpath \"${NEW_RPATH}\" \"\${WPATH}\") ") - else (APPLE) + elseif (CHRPATH_EXEC) + # Looks like CMake's built in RPATH logic isn't quite enough for our + # purposes here - it leaves the build RPATH in place even after assigning + # the new path. + # TODO Need to bundle chrpath so we can reliably do this... + install(CODE " + set(WPATH \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OFILE}\") + execute_process(COMMAND chrpath -r \"${NEW_RPATH}\" \"\${WPATH}\") + ") + else () install(CODE " file(RPATH_CHANGE FILE \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OFILE}\" diff --git a/src/other/ext/itcl.cmake b/src/other/ext/itcl.cmake index 7208c04ebd6..7917dd04b9b 100644 --- a/src/other/ext/itcl.cmake +++ b/src/other/ext/itcl.cmake @@ -134,6 +134,7 @@ if (BRLCAD_ENABLE_TCL) ExternalProject_Target(SHARED itcl ITCL_BLD ${ITCL_INSTDIR} itcl${ITCL_VERSION}/${ITCL_BASENAME}${CMAKE_SHARED_LIBRARY_SUFFIX} SUBDIR itcl${ITCL_VERSION} + RPATH ) ExternalProject_Target(STATIC itclstub ITCL_BLD ${ITCL_INSTDIR} diff --git a/src/other/ext/itk.cmake b/src/other/ext/itk.cmake index 59cf0c88334..9c04f1cd72f 100644 --- a/src/other/ext/itk.cmake +++ b/src/other/ext/itk.cmake @@ -107,6 +107,7 @@ if (BRLCAD_ENABLE_TK) ExternalProject_Target(SHARED itk ITK_BLD ${ITK_INSTDIR} itk${ITK_VERSION}/${ITK_BASENAME}${CMAKE_SHARED_LIBRARY_SUFFIX} SUBDIR itk${ITK_VERSION} + RPATH ) ExternalProject_ByProducts(itk ITK_BLD ${ITK_INSTDIR} ${INCLUDE_DIR}