From ad665d1de9369b6dac1d793cd87be0411510d469 Mon Sep 17 00:00:00 2001 From: Adam Wegrzynek Date: Mon, 8 Mar 2021 11:58:30 +0100 Subject: [PATCH] Use relative RPATHs on Linux and Darwin (#233) --- CMakeLists.txt | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f34e33b..847febf1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,19 +60,29 @@ find_package(ApMon MODULE) find_package(CURL MODULE) find_package(RdKafka CONFIG) +#################################### +# Set OUTPUT vars +#################################### + +set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib") +set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin") +set(INCLUDE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/include") + #################################### # Handle RPATH #################################### include(GNUInstallDirs) -# Build targets with install rpath on Mac to dramatically speed up installation +# Use relative RPATHs set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" isSystemDir) -if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - if("${isSystemDir}" STREQUAL "-1") +if("${isSystemDir}" STREQUAL "-1") + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") set(CMAKE_INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR}") endif() - set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(CMAKE_INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") + endif() endif() unset(isSystemDir) @@ -80,10 +90,6 @@ unset(isSystemDir) # Library #################################### -set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib") -set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin") -set(INCLUDE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/include") - # Backends message(STATUS "Backends") message(STATUS " Compiling StdCout backend")