Skip to content

Commit f78d806

Browse files
awegrzynkostorr
authored andcommitted
RPATH settings should be defined before first target
1 parent 2079ae4 commit f78d806

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
@@ -85,6 +85,22 @@ find_package(Configuration REQUIRED)
8585
find_package(InfoLogger REQUIRED)
8686
find_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
320322
install(TARGETS ReadoutCard ${EXE_NAMES}
321323
EXPORT ReadoutCardTargets

0 commit comments

Comments
 (0)