summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedrich W. H. Kossebau <kossebau@kde.org>2016-11-14 17:10:03 (GMT)
committerFriedrich W. H. Kossebau <kossebau@kde.org>2016-11-14 19:27:39 (GMT)
commitc816a2bce3c6f748f0f546b6398a1485337a3245 (patch)
tree1b330ead4744778d0258af905b316d7ccd151c39
parent68d303e2e37cdc2393187b9a34f5c0e8f1a02216 (diff)
Set RPATH to custom dirs of own and foreign libs; no linking to build dir
Summary: When installing marble to a non-standard system directory the executable loader needs to be informed about the location of the marble libraries. Until now for marble executables this needs to be done via the env var LD_LIBRARY_PATH, which has the disadvantage of needing to be done as explicit separate step and also affects other executables which see this env var. Instead the custom locations of linked libraries can be tagged within the executable, via the RPATH (or RUNPATH) entries, which then is automatically available and also only valid for the given executable. Libmarblewidget only works with data & plugins in installation folders. So when running executables from the build dir (apps, tools, tests) linked to libraries from the build dir, for one things might not work due to not yet installed data/plugins. Or there are API/ABI-related changes done but without reinstallation, so installed plugins and libraries in the build dir are incompatible and will fail with strange behaviour. To protect against that some more when linking the executables in the build dir the RPATH can be set already to the installation location only, so the versions of the libraries in the build dir will not be seen and at least libraries and plugins are consistent. More info e.g. here: https://cmake.org/Wiki/CMake_RPATH_handling http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html Reviewers: rahn, shentey, nienhueser, #marble Reviewed By: nienhueser, #marble Differential Revision: https://phabricator.kde.org/D3358
-rw-r--r--CMakeLists.txt18
-rw-r--r--MarbleMacros.cmake12
-rw-r--r--src/lib/marble/declarative/CMakeLists.txt6
3 files changed, 18 insertions, 18 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 97183ce..b79a312 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,6 +35,24 @@ if (POLICY CMP0063)
cmake_policy(SET CMP0063 NEW)
endif()
+# RPATH/RUNPATH settings
+if (UNIX)
+ # Add CMAKE_INSTALL_FULL_LIBDIR to the RPATH to be used when installing,
+ # but only if it isn't a standard system directory.
+ list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_FULL_LIBDIR}" isSystemLibDir)
+ list(FIND CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_FULL_LIBDIR}" isSystemCxxLibDir)
+ list(FIND CMAKE_C_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_FULL_LIBDIR}" isSystemCLibDir)
+ if("${isSystemLibDir}" STREQUAL "-1" AND "${isSystemCxxLibDir}" STREQUAL "-1" AND "${isSystemCLibDir}" STREQUAL "-1")
+ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
+ endif()
+
+ # Add directories which are in the linker search path (but outside the project)
+ # to the RPATH to be used when installing
+ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+ # no libs or plugins are designed to be used from the build dir, so directly link with install rpath
+ set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
+endif (UNIX)
+
####################################################
# Where to look first for cmake modules,
# before ${CMAKE_ROOT}/Modules/ is checked
diff --git a/MarbleMacros.cmake b/MarbleMacros.cmake
index c1b60a9..0965ceb 100644
--- a/MarbleMacros.cmake
+++ b/MarbleMacros.cmake
@@ -40,12 +40,6 @@ target_link_libraries( ${_target_name} ${${_target_name}_LIBS}
marblewidget )
install( TARGETS ${_target_name} DESTINATION ${MARBLE_PLUGIN_INSTALL_PATH} )
-set_target_properties( ${_target_name} PROPERTIES
- INSTALL_RPATH_USE_LINK_PATH TRUE
- SKIP_BUILD_RPATH TRUE
- BUILD_WITH_INSTALL_RPATH TRUE
- )
-
endmacro( marble_add_plugin _target_name )
# these plugins are slightly different
@@ -60,12 +54,6 @@ target_link_libraries( ${_target_name} ${${_target_name}_LIBS}
marblewidget )
install( TARGETS ${_target_name} DESTINATION ${QT_PLUGINS_DIR}/designer )
-set_target_properties( ${_target_name} PROPERTIES
- INSTALL_RPATH_USE_LINK_PATH TRUE
- SKIP_BUILD_RPATH TRUE
- BUILD_WITH_INSTALL_RPATH TRUE
- )
-
endmacro( marble_add_designer_plugin _target_name )
if( WIN32 )
diff --git a/src/lib/marble/declarative/CMakeLists.txt b/src/lib/marble/declarative/CMakeLists.txt
index 324ca59..f3f6250 100644
--- a/src/lib/marble/declarative/CMakeLists.txt
+++ b/src/lib/marble/declarative/CMakeLists.txt
@@ -52,12 +52,6 @@ if(Qt5Positioning_FOUND)
)
endif()
-set_target_properties( marbledeclarative PROPERTIES
- INSTALL_RPATH_USE_LINK_PATH TRUE
- SKIP_BUILD_RPATH TRUE
- BUILD_WITH_INSTALL_RPATH TRUE
-)
-
if(WIN32)
install(TARGETS marbledeclarative RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX} ARCHIVE DESTINATION lib)
else()