summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorEvan Wilde <etceterawilde@gmail.com>2022-12-31 07:41:16 (GMT)
committerEvan Wilde <etceterawilde@gmail.com>2023-01-19 19:49:24 (GMT)
commit4165eb3d0b21601977b26e8f8af5193c55169cee (patch)
treedefffcae770b9328019490df5135b1df81b20364 /Tests/RunCMake
parent06dfd7b7054aa8d78d736c2e5d84f6f873dd48e3 (diff)
downloadCMake-4165eb3d0b21601977b26e8f8af5193c55169cee.zip
CMake-4165eb3d0b21601977b26e8f8af5193c55169cee.tar.gz
CMake-4165eb3d0b21601977b26e8f8af5193c55169cee.tar.bz2
Ninja: Emit swiftmodule from executable with exports
This patch adds support for tracking the swiftmodules for executables exporting symbols. This fixes a bug in the earlier implementation around emitting the swiftmodule. Previously, the code would use `CMAKE_EXE_EXPORTS_Swift_FLAG` to inject the `-emit-module`, and module path information into the `CMAKE_Swift_LINK_EXECUTABLE` rule. Because Swift skips the build step and only runs during the link phase, these flags were injected in `cmNinjaNormalTargetGenerator::ComputeLinkCmd` instead of `cmLocalGenerator::GetTargetFlags` where it is done normally. Unfortunately, injecting in `ComputeLinkCmd` didn't do anything because we have a `linkCmd` so `ComputeLinkCmd` exits early, before the EXE_EXPORT flags get added to the link command. Instead of playing with that flag, CMake checks `CMAKE_Swift_LINK_EXECUTABLE_WITH_EXPORTS` and uses that as the link rule if it exists and falls back on `CMAKE_Swift_LINK_EXECUTABLE`. I've defined that variable in terms of `CMAKE_Swift_LINK_EXECUTABLE` with the necessary additional flags for emitting the swift module instead. This has the same end effect as the desired behavior, but simplifies things a bit. Since we're generating the swiftmodule for executables with exports, I've also updated the dependency graph to include the swiftmodule as an output in the build dependency graph if the executable has exports. Tests updated: - RunCMake/NoWorkToDo: Ensure that the build graph does not result in unnecessary rebuilds with exporting executables. - SwiftOnly: Ensure that we can consume functions defined in the executable by a library getting linked into said executable.
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/Swift/NoWorkToDo.cmake5
1 files changed, 4 insertions, 1 deletions
diff --git a/Tests/RunCMake/Swift/NoWorkToDo.cmake b/Tests/RunCMake/Swift/NoWorkToDo.cmake
index e86a861..51c2ff3 100644
--- a/Tests/RunCMake/Swift/NoWorkToDo.cmake
+++ b/Tests/RunCMake/Swift/NoWorkToDo.cmake
@@ -1,2 +1,5 @@
enable_language(Swift)
-add_executable(hello hello.swift)
+add_executable(hello1 hello.swift)
+set_target_properties(hello1 PROPERTIES ENABLE_EXPORTS TRUE)
+
+add_executable(hello2 hello.swift)