Skip to content

Commit a718671

Browse files
committed
link swift libraries when building test executables
Add hook to enable passing in the location of the swift runtime libraries so we can include them when building test executables. If we don't do this and we built dispatch as a shared library and enabled swift support the link step fails.
1 parent ded5bab commit a718671

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ if(BSD_OVERLAY_FOUND)
3939
${BSD_OVERLAY_LDFLAGS})
4040
endif()
4141

42+
if(CMAKE_SWIFT_RUNTIME_LIBDIR)
43+
target_link_libraries(bsdtestharness
44+
PRIVATE
45+
-L${CMAKE_SWIFT_RUNTIME_LIBDIR} -lswiftCore -lswiftSwiftOnoneSupport
46+
-Wl,-rpath -Wl,${CMAKE_SWIFT_RUNTIME_LIBDIR})
47+
endif()
48+
4249
function(add_unit_test name)
4350
set(options DISABLED_TEST)
4451
set(single_value_args)
@@ -77,6 +84,12 @@ function(add_unit_test name)
7784
PRIVATE
7885
${BSD_OVERLAY_LDFLAGS})
7986
endif()
87+
if(CMAKE_SWIFT_RUNTIME_LIBDIR)
88+
target_link_libraries(${name}
89+
PRIVATE
90+
-L${CMAKE_SWIFT_RUNTIME_LIBDIR} -lswiftCore -lswiftSwiftOnoneSupport
91+
-Wl,-rpath -Wl,${CMAKE_SWIFT_RUNTIME_LIBDIR})
92+
endif()
8093
target_link_libraries(${name} PRIVATE bsdtests)
8194
add_test(NAME ${name}
8295
COMMAND bsdtestharness $<TARGET_FILE:${name}>)

0 commit comments

Comments
 (0)