diff options
author | Dave Abrahams <dabrahams@adobe.com> | 2024-05-23 00:55:30 (GMT) |
---|---|---|
committer | Dave Abrahams <dabrahams@adobe.com> | 2024-05-24 22:23:41 (GMT) |
commit | 5bb7f8a4dd4671f9343461e5377759b8a4947a4e (patch) | |
tree | 92fc45ac7b467907a0845db25fa4635681b8385c /Source/cmNinjaNormalTargetGenerator.cxx | |
parent | b2e042d77a0bfe21712a2f802668d04df2518bdc (diff) | |
download | CMake-5bb7f8a4dd4671f9343461e5377759b8a4947a4e.zip CMake-5bb7f8a4dd4671f9343461e5377759b8a4947a4e.tar.gz CMake-5bb7f8a4dd4671f9343461e5377759b8a4947a4e.tar.bz2 |
Swift: Use per-config module file locations in multi-config generators
Place `.swiftmodule` files a subdirectory named after the configuration.
Fixes: #25864
Fixes: #25997
- Swift/RunCMakeTest.cmake:
- CMP0157-OLD was enabled for Xcode, where it works.
- A test was added that verifies .swiftmodule's are generated into
separate directories with multi-config generators.
- Tests/SwiftOnly/CMakeLists.txt: tests were added that validate that
cross-subdirectory module dependencies (via target_link_libraries)
work.
Diffstat (limited to 'Source/cmNinjaNormalTargetGenerator.cxx')
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index fefe3a1..77c3e6a 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -1078,19 +1078,6 @@ void cmNinjaNormalTargetGenerator::WriteNvidiaDeviceLinkStatement( this->WriteNvidiaDeviceLinkRule(usedResponseFile, config); } -/// Compute the swift module path for the target, sans any config-specific -/// subdirectory. -/// The returned path will need to be converted to the generator path -static std::string GetSwiftModulePathTree(cmGeneratorTarget const* target) -{ - std::string moduleName = target->GetSwiftModuleName(); - std::string moduleDirectory = target->GetPropertyOrDefault( - "Swift_MODULE_DIRECTORY", - target->LocalGenerator->GetCurrentBinaryDirectory()); - std::string moduleFileName = target->GetSwiftModuleFileName(); - return moduleDirectory + "/" + moduleFileName; -} - void cmNinjaNormalTargetGenerator::WriteLinkStatement( const std::string& config, const std::string& fileConfig, bool firstForConfig) @@ -1205,7 +1192,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement( vars["SWIFT_MODULE_NAME"] = gt->GetSwiftModuleName(); vars["SWIFT_MODULE"] = this->GetLocalGenerator()->ConvertToOutputFormat( - this->ConvertToNinjaPath(GetSwiftModulePathTree(gt)), + this->ConvertToNinjaPath(gt->GetSwiftModulePath(config)), cmOutputConverter::SHELL); vars["SWIFT_SOURCES"] = [this, config]() -> std::string { @@ -1538,7 +1525,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement( if (dependency.Target && dependency.Target->GetLinkerLanguage(config) == "Swift") { std::string swiftmodule = this->ConvertToNinjaPath( - GetSwiftModulePathTree(dependency.Target)); + dependency.Target->GetSwiftModulePath(config)); linkBuild.ImplicitDeps.emplace_back(swiftmodule); } } |