Skip to content

Commit 346ca1e

Browse files
committed
[cmake] Add runpath for libBlocksRuntime.so
Dispatch build leaves artifacts in both the root directory and the src directory, but only the src directory was being added to the runpath, so the libBlocksRuntime.so library might not have been found. Additionally, remove the rpath flags from libdispatch_ldflags, which are used to compile Foundation, but will point to the build directory results. Add those flags instead to a list used for the test binaries. Also, remove Android from the rpath flags, since Android will not work with the build tree rpaths, and will need its own solution. For the time being, do not set any rpath.
1 parent 7e67c02 commit 346ca1e

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

CMakeLists.txt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,22 @@ if(FOUNDATION_ENABLE_LIBDISPATCH)
8181
set(deployment_enable_libdispatch -DDEPLOYMENT_ENABLE_LIBDISPATCH)
8282
set(libdispatch_cflags -I;${FOUNDATION_PATH_TO_LIBDISPATCH_SOURCE};-I;${FOUNDATION_PATH_TO_LIBDISPATCH_BUILD}/src/swift;-Xcc;-fblocks)
8383
set(libdispatch_ldflags -L;${FOUNDATION_PATH_TO_LIBDISPATCH_BUILD};-L;${FOUNDATION_PATH_TO_LIBDISPATCH_BUILD}/src;-ldispatch;-lswiftDispatch)
84-
if(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL Android OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
85-
list(APPEND libdispatch_ldflags -Xlinker;-rpath;-Xlinker;${FOUNDATION_PATH_TO_LIBDISPATCH_BUILD}/src)
86-
endif()
8784
endif()
8885

89-
if(CMAKE_SYSTEM_NAME STREQUAL Android OR CMAKE_SYSTEM_NAME STREQUAL Linux)
86+
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
87+
set(Foundation_RPATH -Xlinker;-rpath;-Xlinker;"\\\$\$ORIGIN")
88+
set(TEST_BINARIES_RPATH -Xlinker;-rpath;-Xlinker;${CMAKE_CURRENT_BINARY_DIR})
89+
if (FOUNDATION_ENABLE_LIBDISPATCH)
90+
list(APPEND TEST_BINARIES_RPATH -Xlinker;-rpath;-Xlinker;${FOUNDATION_PATH_TO_LIBDISPATCH_BUILD}/src;-Xlinker;-rpath;-Xlinker;${FOUNDATION_PATH_TO_LIBDISPATCH_BUILD})
91+
endif()
92+
elseif(CMAKE_SYSTEM_NAME STREQUAL Android)
9093
set(Foundation_RPATH -Xlinker;-rpath;-Xlinker;"\\\$\$ORIGIN")
91-
set(XDG_TEST_HELPER_RPATH -Xlinker;-rpath;-Xlinker;${CMAKE_CURRENT_BINARY_DIR})
9294
elseif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
9395
set(Foundation_RPATH -Xlinker;-rpath;-Xlinker;"\\\$\$ORIGIN")
94-
set(XDG_TEST_HELPER_RPATH -Xlinker;-rpath;-Xlinker;${CMAKE_CURRENT_BINARY_DIR})
96+
set(TEST_BINARIES_RPATH -Xlinker;-rpath;-Xlinker;${CMAKE_CURRENT_BINARY_DIR})
97+
if (FOUNDATION_ENABLE_LIBDISPATCH)
98+
list(APPEND TEST_BINARIES_RPATH -Xlinker;-rpath;-Xlinker;${FOUNDATION_PATH_TO_LIBDISPATCH_BUILD}/src;-Xlinker;-rpath;-Xlinker;${FOUNDATION_PATH_TO_LIBDISPATCH_BUILD})
99+
endif ()
95100
elseif(CMAKE_SYSTEM_NAME STREQUAL Windows)
96101
# FIXME(SR9138) Silence "locally defined symbol '…' imported in function '…'
97102
set(WORKAROUND_SR9138 -Xlinker;-ignore:4049;-Xlinker;-ignore:4217)
@@ -406,7 +411,7 @@ if(ENABLE_TESTING)
406411
-lFoundation
407412
${Foundation_INTERFACE_LIBRARIES}
408413
${WORKAROUND_SR9995}
409-
${XDG_TEST_HELPER_RPATH}
414+
${TEST_BINARIES_RPATH}
410415
SOURCES
411416
TestFoundation/xdgTestHelper/main.swift
412417
SWIFT_FLAGS
@@ -532,6 +537,7 @@ if(ENABLE_TESTING)
532537
-lXCTest
533538
${WORKAROUND_SR9138}
534539
${WORKAROUND_SR9995}
540+
${TEST_BINARIES_RPATH}
535541
$<$<PLATFORM_ID:Windows>:-lWS2_32>
536542
RESOURCES
537543
${CMAKE_SOURCE_DIR}/TestFoundation/Resources/Info.plist

0 commit comments

Comments
 (0)