From 86b774fd9adf108bda24c9eeabda9fff4bb06a78 Mon Sep 17 00:00:00 2001 From: Ahsan Saghir Date: Mon, 10 Jun 2024 20:55:48 +0000 Subject: [PATCH] Update RPATHs --- .../cmake/ROCMInstallTargets.cmake | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/share/rocmcmakebuildtools/cmake/ROCMInstallTargets.cmake b/share/rocmcmakebuildtools/cmake/ROCMInstallTargets.cmake index 2d406866..70b2d772 100644 --- a/share/rocmcmakebuildtools/cmake/ROCMInstallTargets.cmake +++ b/share/rocmcmakebuildtools/cmake/ROCMInstallTargets.cmake @@ -131,6 +131,10 @@ function(rocm_install_targets) set(EXPORT_FILE ${PARSE_EXPORT}) endif() + if(POLICY CMP0095) + cmake_policy(SET CMP0095 NEW) + endif() + if(PARSE_PREFIX) set(PREFIX_DIR ${PARSE_PREFIX}) if(PARSE_PRIVATE) @@ -200,24 +204,41 @@ 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") + if(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") + set_property(TARGET ${TARGET} APPEND PROPERTY INSTALL_RPATH "$ORIGIN/../lib") + message("------- POLICY CMP0095 INSTALL RPATH.") else() - set_property(TARGET ${TARGET} APPEND PROPERTY INSTALL_RPATH "\\\${ORIGIN}/${PROJECT_NAME}/lib") + set_property(TARGET ${TARGET} APPEND PROPERTY + INSTALL_RPATH "\\\${ORIGIN}/../lib") + message("------- POLICY CMP0095 NOT SET - INSTALL RPATH.") endif() - endif() - set(export_arg EXPORT ${EXPORT_FILE}) - if(T_TYPE STREQUAL "EXECUTABLE") + # Adding RPATH to the private libraries. if(PARSE_PRIVATE) if(POLICY CMP0095) - set_property(TARGET ${TARGET} APPEND PROPERTY INSTALL_RPATH "${ORIGIN}/../lib/${PROJECT_NAME}/lib") + set_property(TARGET ${TARGET} APPEND PROPERTY INSTALL_RPATH "$ORIGIN/../../") + message("------- POLICY CMP0095 INSTALL RPATH.") + else() + set_property(TARGET ${TARGET} APPEND PROPERTY + INSTALL_RPATH "\\\${ORIGIN}/../../") + message("------- POLICY CMP0095 NOT SET - INSTALL RPATH.") + endif() + # Adding RPATH to libraries/executables that are not private. + else() + if(POLICY CMP0095) + set_property(TARGET ${TARGET} APPEND PROPERTY INSTALL_RPATH "$ORIGIN/../lib/${PROJECT_NAME}/lib") + message("------- POLICY CMP0095 INSTALL RPATH.") else() set_property(TARGET ${TARGET} APPEND PROPERTY - INSTALL_RPATH "\\\${ORIGIN}/../lib/${PROJECT_NAME}/lib") + INSTALL_RPATH "\\\${ORIGIN}/../lib/${PROJECT_NAME}/lib") + message("------- POLICY CMP0095 NOT SET - INSTALL RPATH.") endif() endif() + endif() + + set(export_arg EXPORT ${EXPORT_FILE}) + if(T_TYPE STREQUAL "EXECUTABLE") unset(export_arg) endif() install(