diff --git a/.cmake/isce2_buildflags.cmake b/.cmake/isce2_buildflags.cmake index 447f0c0..a5b28b4 100644 --- a/.cmake/isce2_buildflags.cmake +++ b/.cmake/isce2_buildflags.cmake @@ -14,13 +14,15 @@ set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED y) set(CMAKE_CXX_EXTENSIONS n) -# TODO (fix RPATHs) -# We have to hack our RPATHs a bit for these shared libraries to be -# loaded by others on the install-side. Maybe these libraries should -# be combined and/or installed to a common ISCE2 lib directory. -# Is there a semantic way to propagate their RPATHs -# without using these global variables? +include(GNUInstallDirs) + +# add automatically determined parts of the RPATH, which point to directories +# outside of the build tree, to the install RPATH set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON) -list(APPEND CMAKE_INSTALL_RPATH - ${CMAKE_INSTALL_PREFIX}/${ISCE2_PKG}/components/isceobj/Util - ) + +# the RPATH to be used when installing, but only if it's not a system directory +set(abs_libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) +list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES ${abs_libdir} isSystemDir) +if("${isSystemDir}" STREQUAL "-1") + list(APPEND CMAKE_INSTALL_RPATH ${abs_libdir}) +endif() diff --git a/components/isceobj/Util/CMakeLists.txt b/components/isceobj/Util/CMakeLists.txt index 6905f71..1975968 100644 --- a/components/isceobj/Util/CMakeLists.txt +++ b/components/isceobj/Util/CMakeLists.txt @@ -130,7 +130,8 @@ target_include_directories(combinedLib INTERFACE install(TARGETS utilLib combinedLib - LIBRARY DESTINATION lib) + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ) InstallSameDir( combinedlibmodule