Skip to content

Commit 71f4419

Browse files
committed
Fixes for building tests with Swift enabled
Need to link the Swift runtime libraries and set rpath when we included the Swift overlay into libdisaptch.so. If we don't, linking the test executables will fail.
1 parent a77dbb6 commit 71f4419

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ if(BSD_OVERLAY_FOUND)
3838
PRIVATE
3939
${BSD_OVERLAY_LDFLAGS})
4040
endif()
41+
if(CMAKE_SWIFT_RUNTIME_LIBDIR)
42+
target_link_libraries(bsdtestharness PRIVATE -L${CMAKE_SWIFT_RUNTIME_LIBDIR} -lswiftCore -lswiftSwiftOnoneSupport -Wl,-rpath -Wl,${CMAKE_SWIFT_RUNTIME_LIBDIR})
43+
endif()
4144

4245
function(add_unit_test name)
4346
set(options DISABLED_TEST)
@@ -86,6 +89,9 @@ function(add_unit_test name)
8689
${BSD_OVERLAY_LDFLAGS})
8790
endif()
8891
target_link_libraries(${name} PRIVATE bsdtests)
92+
if(CMAKE_SWIFT_RUNTIME_LIBDIR)
93+
target_link_libraries(${name} PRIVATE -L${CMAKE_SWIFT_RUNTIME_LIBDIR} -lswiftCore -lswiftSwiftOnoneSupport -Wl,-rpath -Wl,${CMAKE_SWIFT_RUNTIME_LIBDIR})
94+
endif()
8995
add_test(NAME ${name}
9096
COMMAND bsdtestharness $<TARGET_FILE:${name}>)
9197
set_tests_properties(${name}

0 commit comments

Comments
 (0)