summaryrefslogtreecommitdiffstats
path: root/Tests/SwiftMixLib
diff options
context:
space:
mode:
authorEvan Wilde <etceterawilde@gmail.com>2024-08-16 22:48:58 (GMT)
committerEvan Wilde <etceterawilde@gmail.com>2024-08-19 18:54:12 (GMT)
commit0b0c70d1bf6210a228f0f57f40e9a6570dc41a88 (patch)
tree2d05deabf914924361ff001736ee8c2fe2745124 /Tests/SwiftMixLib
parent48c0b0119746fb87e3510fc99340be732558f9b9 (diff)
downloadCMake-0b0c70d1bf6210a228f0f57f40e9a6570dc41a88.zip
CMake-0b0c70d1bf6210a228f0f57f40e9a6570dc41a88.tar.gz
CMake-0b0c70d1bf6210a228f0f57f40e9a6570dc41a88.tar.bz2
Swift: Enable SwiftMixLib Test on Windows
The SwiftMixLib test was failing on Windows due to a missing link against swiftCore. On macOS and Linux, there are mechanisms for extracting the libraries that the object depends on and passing that to the linker so that the library dependencies don't need to be listed explicitly. The Windows Swift toolchain does not have this mechanism. In the future, it would likely make sense for CMake to pass some of the implicitly required libraries for linking Swift via `CMAKE_Swift_IMPLICIT_LINK_LIBRARIES`. Unlike the normal mechanisms though, these libraries would need to be passed even when the link language is Swift. For now though, we should get the test up and running again. Fixes: #25573
Diffstat (limited to 'Tests/SwiftMixLib')
-rw-r--r--Tests/SwiftMixLib/CMakeLists.txt12
1 files changed, 12 insertions, 0 deletions
diff --git a/Tests/SwiftMixLib/CMakeLists.txt b/Tests/SwiftMixLib/CMakeLists.txt
index d23c6ba..c2cfb8f 100644
--- a/Tests/SwiftMixLib/CMakeLists.txt
+++ b/Tests/SwiftMixLib/CMakeLists.txt
@@ -10,3 +10,15 @@ target_link_libraries(Swifty PUBLIC SwiftMixedLib)
add_executable(c_main main.c)
target_link_libraries(c_main PUBLIC SwiftMixedLib)
+
+if(WIN32)
+ # TODO: On macOS and Linux, Swift has mechanism for determining what libraries
+ # an object, or objects from a static archive, need to link against,
+ # which is how the Swift driver is able to determine that `c_main`
+ # needs to link swiftCore. Windows does not have this mechanism.
+ # Eventually CMake should learn how to do this, explicitly forwarding
+ # the required library to the link command when linking a static
+ # archive containing Swift sources into something else, even if the
+ # linker language is Swift.
+ target_link_libraries(c_main PRIVATE swiftCore)
+endif()