Skip to content

Commit 801b4cd

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 020f5a4 commit 801b4cd

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
@@ -97,17 +97,22 @@ if(FOUNDATION_ENABLE_LIBDISPATCH)
9797
set(deployment_enable_libdispatch -DDEPLOYMENT_ENABLE_LIBDISPATCH)
9898
set(libdispatch_cflags -I;${FOUNDATION_PATH_TO_LIBDISPATCH_SOURCE};-I;${FOUNDATION_PATH_TO_LIBDISPATCH_BUILD}/src/swift;-Xcc;-fblocks)
9999
set(libdispatch_ldflags -L;${FOUNDATION_PATH_TO_LIBDISPATCH_BUILD};-L;${FOUNDATION_PATH_TO_LIBDISPATCH_BUILD}/src;-ldispatch;-lswiftDispatch)
100-
if(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL Android OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
101-
list(APPEND libdispatch_ldflags -Xlinker;-rpath;-Xlinker;${FOUNDATION_PATH_TO_LIBDISPATCH_BUILD}/src)
102-
endif()
103100
endif()
104101

105-
if(CMAKE_SYSTEM_NAME STREQUAL Android OR CMAKE_SYSTEM_NAME STREQUAL Linux)
102+
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
103+
set(Foundation_RPATH -Xlinker;-rpath;-Xlinker;"\\\$\$ORIGIN")
104+
set(TEST_BINARIES_RPATH -Xlinker;-rpath;-Xlinker;${CMAKE_CURRENT_BINARY_DIR})
105+
if (FOUNDATION_ENABLE_LIBDISPATCH)
106+
list(APPEND TEST_BINARIES_RPATH -Xlinker;-rpath;-Xlinker;${FOUNDATION_PATH_TO_LIBDISPATCH_BUILD}/src;-Xlinker;-rpath;-Xlinker;${FOUNDATION_PATH_TO_LIBDISPATCH_BUILD})
107+
endif()
108+
elseif(CMAKE_SYSTEM_NAME STREQUAL Android)
106109
set(Foundation_RPATH -Xlinker;-rpath;-Xlinker;"\\\$\$ORIGIN")
107-
set(XDG_TEST_HELPER_RPATH -Xlinker;-rpath;-Xlinker;${CMAKE_CURRENT_BINARY_DIR})
108110
elseif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
109111
set(Foundation_RPATH -Xlinker;-rpath;-Xlinker;"\\\$\$ORIGIN")
110-
set(XDG_TEST_HELPER_RPATH -Xlinker;-rpath;-Xlinker;${CMAKE_CURRENT_BINARY_DIR})
112+
set(TEST_BINARIES_RPATH -Xlinker;-rpath;-Xlinker;${CMAKE_CURRENT_BINARY_DIR})
113+
if (FOUNDATION_ENABLE_LIBDISPATCH)
114+
list(APPEND TEST_BINARIES_RPATH -Xlinker;-rpath;-Xlinker;${FOUNDATION_PATH_TO_LIBDISPATCH_BUILD}/src;-Xlinker;-rpath;-Xlinker;${FOUNDATION_PATH_TO_LIBDISPATCH_BUILD})
115+
endif ()
111116
elseif(CMAKE_SYSTEM_NAME STREQUAL Windows)
112117
# FIXME(SR9138) Silence "locally defined symbol '…' imported in function '…'
113118
set(WORKAROUND_SR9138 -Xlinker;-ignore:4049;-Xlinker;-ignore:4217)
@@ -385,7 +390,7 @@ if(ENABLE_TESTING)
385390
-L${CMAKE_CURRENT_BINARY_DIR}
386391
-lFoundation
387392
${Foundation_INTERFACE_LIBRARIES}
388-
${XDG_TEST_HELPER_RPATH}
393+
${TEST_BINARIES_RPATH}
389394
SOURCES
390395
TestFoundation/xdgTestHelper/main.swift
391396
SWIFT_FLAGS
@@ -507,6 +512,7 @@ if(ENABLE_TESTING)
507512
-L${FOUNDATION_PATH_TO_XCTEST_BUILD}
508513
-lXCTest
509514
${WORKAROUND_SR9138}
515+
${TEST_BINARIES_RPATH}
510516
$<$<PLATFORM_ID:Windows>:-lWS2_32>
511517
RESOURCES
512518
${CMAKE_SOURCE_DIR}/TestFoundation/Resources/Info.plist

0 commit comments

Comments
 (0)