Skip to content

Commit 0994e0b

Browse files
authored
RPATH settings should be defined before first target (#176)
1 parent b440b77 commit 0994e0b

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

CMakeLists.txt

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@ find_package(Git QUIET)
5858
find_package(ApMon MODULE)
5959
find_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
235237
install(TARGETS Monitoring 5-Benchmark
236238
EXPORT MonitoringTargets

0 commit comments

Comments
 (0)