@@ -58,6 +58,22 @@ find_package(Git QUIET)
5858find_package (ApMon MODULE)
5959find_package (RdKafka CONFIG)
6060
61+ ####################################
62+ # Handle RPATH
63+ ####################################
64+ include (GNUInstallDirs)
65+
66+ # Build targets with install rpath on Mac to dramatically speed up installation
67+ set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
68+ list (FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX} /${CMAKE_INSTALL_LIBDIR} " isSystemDir)
69+ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
70+ if ("${isSystemDir} " STREQUAL "-1" )
71+ set (CMAKE_INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR} " )
72+ endif ()
73+ set (CMAKE_BUILD_WITH_INSTALL_RPATH TRUE )
74+ endif ()
75+ unset (isSystemDir)
76+
6177####################################
6278# Library
6379####################################
@@ -217,20 +233,6 @@ endforeach()
217233# Install
218234####################################
219235
220- include (GNUInstallDirs)
221-
222- # Build targets with install rpath on Mac to dramatically speed up installation
223- # https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
224- set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
225- list (FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX} /${CMAKE_INSTALL_LIBDIR} " isSystemDir)
226- if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
227- if ("${isSystemDir} " STREQUAL "-1" )
228- set (CMAKE_INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR} " )
229- endif ()
230- set (CMAKE_BUILD_WITH_INSTALL_RPATH TRUE )
231- endif ()
232- unset (isSystemDir)
233-
234236# Install library
235237install (TARGETS Monitoring 5-Benchmark
236238 EXPORT MonitoringTargets
0 commit comments