Skip to content

Commit

Permalink
Fix potential incomplete RPath for installed library
Browse files Browse the repository at this point in the history
  • Loading branch information
nmellado committed Dec 12, 2017
1 parent ff9e55d commit e459673
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Expand Up @@ -51,6 +51,8 @@ endif()
################################################################################
include(cmake/ConfigureCompiler.cmake)

include(cmake/ConfigureRPath.cmake)

################################################################################
## Apply user-defined configuration
################################################################################
Expand Down
2 changes: 1 addition & 1 deletion 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
Expand Down
24 changes: 24 additions & 0 deletions 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")

0 comments on commit e459673

Please sign in to comment.