From a71867119375c21ecb47ace37101b2e9eebd975a Mon Sep 17 00:00:00 2001 From: David Grove Date: Fri, 30 Jun 2017 14:35:37 -0400 Subject: [PATCH] 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. --- tests/CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 37ab00215..b9d7acd59 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -39,6 +39,13 @@ if(BSD_OVERLAY_FOUND) ${BSD_OVERLAY_LDFLAGS}) endif() +if(CMAKE_SWIFT_RUNTIME_LIBDIR) + target_link_libraries(bsdtestharness + PRIVATE + -L${CMAKE_SWIFT_RUNTIME_LIBDIR} -lswiftCore -lswiftSwiftOnoneSupport + -Wl,-rpath -Wl,${CMAKE_SWIFT_RUNTIME_LIBDIR}) +endif() + function(add_unit_test name) set(options DISABLED_TEST) set(single_value_args) @@ -77,6 +84,12 @@ function(add_unit_test name) PRIVATE ${BSD_OVERLAY_LDFLAGS}) endif() + if(CMAKE_SWIFT_RUNTIME_LIBDIR) + target_link_libraries(${name} + PRIVATE + -L${CMAKE_SWIFT_RUNTIME_LIBDIR} -lswiftCore -lswiftSwiftOnoneSupport + -Wl,-rpath -Wl,${CMAKE_SWIFT_RUNTIME_LIBDIR}) + endif() target_link_libraries(${name} PRIVATE bsdtests) add_test(NAME ${name} COMMAND bsdtestharness $)