diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f00aa44..8c461280 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,14 +96,14 @@ endif () set( CMAKE_SKIP_BUILD_RPATH FALSE ) set( CMAKE_BUILD_WITH_INSTALL_RPATH FALSE ) -if ( CMAKE_SYSTEM_NAME STREQUAL "Darwin" ) - set( rpath_prefix "@loader_path" ) -else() - set( rpath_prefix "\\$ORIGIN" ) -endif() -list( INSERT 0 CMAKE_INSTALL_RPATH "${rpath_prefix}/../lib" ) 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") + if ( NOT GIT_EXECUTABLE ) find_package( Git ) if ( NOT GIT_FOUND )