Skip to content

Commit 011e7ea

Browse files
committed
build: refactor the rpath handling
The rpath handling uses linker flags specific to the ELF linkers. This is in preparation to build for Windows which does does not have the concept of `DT_RPATH`.
1 parent 72a8dab commit 011e7ea

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,12 @@ endif()
102102

103103
if(CMAKE_SYSTEM_NAME STREQUAL Android OR CMAKE_SYSTEM_NAME STREQUAL Linux)
104104
set(deployment_target -DDEPLOYMENT_TARGET_LINUX)
105+
set(Foundation_rpath_flags -Xlinker;-rpath;-Xlinker;"\\\$\$ORIGIN")
105106
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
106107
set(deployment_target -DDEPLOYMENT_TARGET_MACOSX)
107108
elseif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
108109
set(deployment_target -DDEPLOYMENT_TARGET_FREEBSD)
110+
set(Foundation_rpath_flags -Xlinker;-rpath;-Xlinker;"\\\$\$ORIGIN")
109111
elseif(CMAKE_SYSTEM_NAME STREQUAL Windows)
110112
set(deployment_target -DDEPLOYMENT_TARGET_WINDOWS)
111113
endif()
@@ -287,7 +289,7 @@ add_swift_library(Foundation
287289
${libdispatch_ldflags}
288290
-L${CMAKE_CURRENT_BINARY_DIR}
289291
-luuid
290-
-Xlinker;-rpath;-Xlinker;"\\\$\$ORIGIN"
292+
${Foundation_rpath_flags}
291293
SWIFT_FLAGS
292294
-DDEPLOYMENT_RUNTIME_SWIFT
293295
${deployment_enable_libdispatch}

0 commit comments

Comments
 (0)