@@ -85,6 +85,22 @@ find_package(Configuration REQUIRED)
8585find_package (InfoLogger REQUIRED)
8686find_package (PDA)
8787
88+ ####################################
89+ # RPATH
90+ ####################################
91+ include (GNUInstallDirs)
92+
93+ # https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
94+ set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
95+ list (FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX} /${CMAKE_INSTALL_LIBDIR} " isSystemDir)
96+ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
97+ if ("${isSystemDir} " STREQUAL "-1" )
98+ set (CMAKE_INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR} " )
99+ endif ()
100+ set (CMAKE_BUILD_WITH_INSTALL_RPATH TRUE )
101+ endif ()
102+ unset (isSystemDir)
103+
88104####################################
89105# Module, library and executable definition
90106####################################
@@ -302,20 +318,6 @@ endforeach()
302318# Install
303319####################################
304320
305- include (GNUInstallDirs)
306-
307- # Build targets with install rpath on Mac to dramatically speed up installation
308- # https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
309- set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
310- list (FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX} /${CMAKE_INSTALL_LIBDIR} " isSystemDir)
311- if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
312- if ("${isSystemDir} " STREQUAL "-1" )
313- set (CMAKE_INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR} " )
314- endif ()
315- set (CMAKE_BUILD_WITH_INSTALL_RPATH TRUE )
316- endif ()
317- unset (isSystemDir)
318-
319321# Install library and executables
320322install (TARGETS ReadoutCard ${EXE_NAMES}
321323 EXPORT ReadoutCardTargets
0 commit comments