From 9475601d064d012e3419f211c727cf1dceb05ed7 Mon Sep 17 00:00:00 2001 From: Ahsan Saghir <142340507+ahsan-ca@users.noreply.github.com> Date: Tue, 25 Jun 2024 14:36:36 -0400 Subject: [PATCH] Update RPATH to binaries for PRIVATE lib changes (#197) * Update RPATHs * Remove debug messages and re-indent comments * Use CMP0095 NEW policy for paths and update BIN_INSTALL_DIR paths for private binaries * Remove setting CMP0095 to NEW --- .../cmake/ROCMInstallTargets.cmake | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/share/rocmcmakebuildtools/cmake/ROCMInstallTargets.cmake b/share/rocmcmakebuildtools/cmake/ROCMInstallTargets.cmake index 8f4fc5f9..72fdb3bb 100644 --- a/share/rocmcmakebuildtools/cmake/ROCMInstallTargets.cmake +++ b/share/rocmcmakebuildtools/cmake/ROCMInstallTargets.cmake @@ -134,7 +134,7 @@ function(rocm_install_targets) if(PARSE_PREFIX) set(PREFIX_DIR ${PARSE_PREFIX}) if(PARSE_PRIVATE) - set(BIN_INSTALL_DIR ${PARSE_PREFIX}/${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}) + set(BIN_INSTALL_DIR ${PARSE_PREFIX}/${ROCM_INSTALL_LIBDIR}/${PROJECT_NAME}/bin) set(LIB_INSTALL_DIR ${PARSE_PREFIX}/${ROCM_INSTALL_LIBDIR}/${PROJECT_NAME}/lib) set(INCLUDE_INSTALL_DIR ${PARSE_PREFIX}/${ROCM_INSTALL_LIBDIR}/${PROJECT_NAME}/include) else() @@ -144,7 +144,7 @@ function(rocm_install_targets) endif() elseif(ENABLE_ASAN_PACKAGING) if(PARSE_PRIVATE) - set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR}/asan/${PROJECT_NAME}) + set(BIN_INSTALL_DIR ${ROCM_INSTALL_LIBDIR}/asan/${PROJECT_NAME}/bin) set(LIB_INSTALL_DIR ${ROCM_INSTALL_LIBDIR}/asan/${PROJECT_NAME}/lib) set(INCLUDE_INSTALL_DIR ${ROCM_INSTALL_LIBDIR}/asan/${PROJECT_NAME}/include) else() @@ -154,7 +154,7 @@ function(rocm_install_targets) endif() else() if(PARSE_PRIVATE) - set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}) + set(BIN_INSTALL_DIR ${ROCM_INSTALL_LIBDIR}/${PROJECT_NAME}/bin) set(LIB_INSTALL_DIR ${ROCM_INSTALL_LIBDIR}/${PROJECT_NAME}/lib) set(INCLUDE_INSTALL_DIR ${ROCM_INSTALL_LIBDIR}/${PROJECT_NAME}/include) else() @@ -200,24 +200,19 @@ function(rocm_install_targets) foreach(TARGET IN LISTS PARSE_TARGETS) get_target_property(T_TYPE ${TARGET} TYPE) - if(NOT PARSE_PRIVATE AND NOT T_TYPE STREQUAL "INTERFACE_LIBRARY") - # TODO: Create a function to set INSTALL_RPATH - if(POLICY CMP0095) - set_property(TARGET ${TARGET} APPEND PROPERTY INSTALL_RPATH "${ORIGIN}/${PROJECT_NAME}/lib") + if(NOT T_TYPE STREQUAL "INTERFACE_LIBRARY") + set_property(TARGET ${TARGET} APPEND PROPERTY INSTALL_RPATH "$ORIGIN/../lib") + if(PARSE_PRIVATE) + # Adding RPATH to private binaries to point to public libraries. + set_property(TARGET ${TARGET} APPEND PROPERTY INSTALL_RPATH "$ORIGIN/../../") else() - set_property(TARGET ${TARGET} APPEND PROPERTY INSTALL_RPATH "\\\${ORIGIN}/${PROJECT_NAME}/lib") + # Adding RPATH to public binaries to point to private libraries. + set_property(TARGET ${TARGET} APPEND PROPERTY INSTALL_RPATH "$ORIGIN/../lib/${PROJECT_NAME}/lib") endif() endif() + set(export_arg EXPORT ${EXPORT_FILE}) if(T_TYPE STREQUAL "EXECUTABLE") - if(PARSE_PRIVATE) - if(POLICY CMP0095) - set_property(TARGET ${TARGET} APPEND PROPERTY INSTALL_RPATH "${ORIGIN}/../lib/${PROJECT_NAME}/lib") - else() - set_property(TARGET ${TARGET} APPEND PROPERTY - INSTALL_RPATH "\\\${ORIGIN}/../lib/${PROJECT_NAME}/lib") - endif() - endif() unset(export_arg) endif() install(