Skip to content

Commit 7dc982e

Browse files
committed
[CMake] fix runpath for ELF platforms
Remove the absolute path to the host stdlib for libswiftDispatch.so and add $ORIGIN to it and libdispatch.so.
1 parent ae5c03e commit 7dc982e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
155155
"-Xlinker -alias_list -Xlinker ${PROJECT_SOURCE_DIR}/xcodeconfig/libdispatch.aliases")
156156
endif()
157157

158+
if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows")
159+
set_target_properties(dispatch PROPERTIES INSTALL_RPATH "$ORIGIN")
160+
endif()
161+
158162
if(ENABLE_SWIFT)
159163
add_subdirectory(swift)
160164
endif()

src/swift/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,7 @@ if(NOT BUILD_SHARED_LIBS)
5959
install(TARGETS DispatchStubs
6060
EXPORT dispatchExports
6161
DESTINATION ${INSTALL_TARGET_DIR})
62+
elseif(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows")
63+
target_link_options(swiftDispatch PRIVATE "SHELL:-no-toolchain-stdlib-rpath")
64+
set_target_properties(swiftDispatch PROPERTIES INSTALL_RPATH "$ORIGIN")
6265
endif()

0 commit comments

Comments
 (0)