From 55dd9b16d5c9f3641bcb236282fb06983df1a5dd Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Thu, 10 Aug 2017 16:35:21 +0000 Subject: CMake: Update RPATH during installation. If we're installing into a non-system prefix on UNIX or Linux, make sure CMake updates our RPATHs accordingly. Change-Id: Ia6eaa6533c996a8228cff25e9d2032b223781681 Reviewed-on: https://code.wireshark.org/review/23040 Petri-Dish: Gerald Combs Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs --- CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index aa8e74871e..f4c27ebcac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,9 +182,19 @@ if(NOT LIBRARY_OUTPUT_PATH) "Single output directory for building all libraries.") endif() -# Under linux the release mode (CMAKE_BUILD_TYPE=release) defines NDEBUG +# Under Linux the release mode (CMAKE_BUILD_TYPE=release) defines NDEBUG #Defines CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_DATADIR, etc ... include(CMakeInstallDirs) +# Make sure our executables can can load our libraries if we install into +# a non-default directory on UNIX/Linux. +# https://cmake.org/Wiki/CMake_RPATH_handling +if(NOT (WIN32 OR APPLE)) + LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" IS_SYSTEM_DIR) + if("${IS_SYSTEM_DIR}" STREQUAL "-1") + SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") + SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + endif("${IS_SYSTEM_DIR}" STREQUAL "-1") +endif() # Banner shown at top right of Qt welcome screen. if(DEFINED ENV{WIRESHARK_VERSION_FLAVOR}) -- cgit v1.2.3