From: Jiri Slaby Date: Wed, 27 Jul 2022 09:22:37 +0200 Subject: CMakeLists: use absolute libdir in rpath handling Patch-mainline: no References: rpath fix The original rpath handling in the wiki[1] uses "${CMAKE_INSTALL_PREFIX}/lib". But here, "${CMAKE_INSTALL_LIBDIR}" is used. While the former is absolute, the latter needs not. That causes troubles as rpath can be set to something like "lib64" only. That is bogus. So fix this by using absolute "${CMAKE_INSTALL_FULL_LIBDIR}" from GNUInstallDirs and handles the paths correctly. [1] https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling#always-full-rpath Signed-off-by: Jiri Slaby --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 465fd913..1a0bf286 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,7 @@ find_package(ZLIB) include_directories(${ZLIB_INCLUDE_DIR}) include_directories(${minisat_SOURCE_DIR}) include (GenerateExportHeader) +include(GNUInstallDirs) #-------------------------------------------------------------------------------------------------- # Compile flags: @@ -76,16 +77,16 @@ else () # (but later on when installing) SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) - SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}") + SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}") # add the automatically determined parts of the RPATH # which point to directories outside the build tree to the install RPATH SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # the RPATH to be used when installing, but only if it's not a system directory - LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_LIBDIR}" isSystemDir) + LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_FULL_LIBDIR}" isSystemDir) IF("${isSystemDir}" STREQUAL "-1") - SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}") + SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}") ENDIF("${isSystemDir}" STREQUAL "-1") if (APPLE) -- 2.35.3