From 0994e0b20a3373550f67d4f61b2b75767524f243 Mon Sep 17 00:00:00 2001 From: Adam Wegrzynek Date: Wed, 12 Feb 2020 09:32:38 +0100 Subject: [PATCH] RPATH settings should be defined before first target (#176) --- CMakeLists.txt | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d53307e1a..a65d3c5d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,22 @@ find_package(Git QUIET) find_package(ApMon MODULE) find_package(RdKafka CONFIG) +#################################### +# Handle RPATH +#################################### +include(GNUInstallDirs) + +# Build targets with install rpath on Mac to dramatically speed up installation +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") + set(CMAKE_INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR}") + endif() + set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) +endif() +unset(isSystemDir) + #################################### # Library #################################### @@ -217,20 +233,6 @@ endforeach() # Install #################################### -include(GNUInstallDirs) - -# Build targets with install rpath on Mac to dramatically speed up installation -# https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling -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") - set(CMAKE_INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR}") - endif() - set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) -endif() -unset(isSystemDir) - # Install library install(TARGETS Monitoring 5-Benchmark EXPORT MonitoringTargets