From e4596735131dc39997344d33f1ace5f0b3878c49 Mon Sep 17 00:00:00 2001 From: Nicolas Mellado Date: Tue, 12 Dec 2017 14:29:23 +0100 Subject: [PATCH] Fix potential incomplete RPath for installed library Solution taken from https://cmake.org/Wiki/CMake_RPATH_handling --- CMakeLists.txt | 2 ++ cmake/Config.cmake.in | 2 +- cmake/ConfigureRPath.cmake | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 cmake/ConfigureRPath.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f824ded..887dd12d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,8 @@ endif() ################################################################################ include(cmake/ConfigureCompiler.cmake) +include(cmake/ConfigureRPath.cmake) + ################################################################################ ## Apply user-defined configuration ################################################################################ diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in index c9394283..6ae886e6 100644 --- a/cmake/Config.cmake.in +++ b/cmake/Config.cmake.in @@ -1,4 +1,4 @@ -# - Config file for the FooBar package +# - Config file for the Super4PCS package # It defines the following variables # Super4PCS_INCLUDE_DIRS - include directories for Super4PCS # Super4PCS_LIB_DIR - libraries to link against diff --git a/cmake/ConfigureRPath.cmake b/cmake/ConfigureRPath.cmake new file mode 100644 index 00000000..00d8d0b8 --- /dev/null +++ b/cmake/ConfigureRPath.cmake @@ -0,0 +1,24 @@ +## This script comes from https://cmake.org/Wiki/CMake_RPATH_handling#Always_full_RPATH +# +# It is designed 'to make sure that the required libraries are always found +# independent from LD_LIBRARY_PATH and the install location' + +# use, i.e. don't skip the full RPATH for the build tree +SET(CMAKE_SKIP_BUILD_RPATH FALSE) + +# when building, don't use the install RPATH already +# (but later on when installing) +SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) + +SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + +# 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_PREFIX}/lib" isSystemDir) +IF("${isSystemDir}" STREQUAL "-1") + SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") +ENDIF("${isSystemDir}" STREQUAL "-1")