summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2020-03-10 14:16:07 +0000
committerKitware Robot <kwrobot@kitware.com>2020-03-10 10:16:17 -0400
commit2427bbf01cf6671a9b4a266df2bb7df8855cee2b (patch)
treeb5b025cff39d4266dfbc4ee935f50727f99368c2
parentcb84575b0d181b671901d97be15e35db1876345e (diff)
parent65b3848de0ae6251858dd12c97bff8110cb845f1 (diff)
downloadcmake-2427bbf01cf6671a9b4a266df2bb7df8855cee2b.tar.gz
Merge topic 'swift-ninja-multiconfig' into release-3.17
65b3848de0 Swift: support Ninja Multi-Config Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4440
-rw-r--r--Modules/CMakeDetermineSwiftCompiler.cmake2
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx6
-rw-r--r--Source/cmNinjaTargetGenerator.cxx3
-rw-r--r--Tests/RunCMake/Swift/L.swift1
-rw-r--r--Tests/RunCMake/Swift/RunCMakeTest.cmake6
-rw-r--r--Tests/RunCMake/Swift/SwiftSimple.cmake2
6 files changed, 15 insertions, 5 deletions
diff --git a/Modules/CMakeDetermineSwiftCompiler.cmake b/Modules/CMakeDetermineSwiftCompiler.cmake
index 9aafe4820f..688133f34f 100644
--- a/Modules/CMakeDetermineSwiftCompiler.cmake
+++ b/Modules/CMakeDetermineSwiftCompiler.cmake
@@ -16,7 +16,7 @@ if("${CMAKE_GENERATOR}" STREQUAL "Xcode")
endif()
set(CMAKE_Swift_COMPILER_XCODE_TYPE sourcecode.swift)
_cmake_find_compiler_path(Swift)
-elseif("${CMAKE_GENERATOR}" STREQUAL "Ninja")
+elseif("${CMAKE_GENERATOR}" MATCHES "^Ninja")
if(CMAKE_Swift_COMPILER)
_cmake_find_compiler_path(Swift)
else()
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 0a6da910cd..885703fb32 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -873,11 +873,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
cmOutputConverter::SHELL);
}(vars["SWIFT_MODULE_NAME"]);
+ const std::string map = cmStrCat(gt->GetSupportDirectory(), '/', config,
+ '/', "output-file-map.json");
vars["SWIFT_OUTPUT_FILE_MAP"] =
this->GetLocalGenerator()->ConvertToOutputFormat(
- this->ConvertToNinjaPath(gt->GetSupportDirectory() +
- "/output-file-map.json"),
- cmOutputConverter::SHELL);
+ this->ConvertToNinjaPath(map), cmOutputConverter::SHELL);
vars["SWIFT_SOURCES"] = [this, config]() -> std::string {
std::vector<cmSourceFile const*> sources;
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 0e746789e1..abf12f82ed 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -953,7 +953,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements(
if (!this->Configs[config].SwiftOutputMap.empty()) {
std::string const mapFilePath =
- this->GeneratorTarget->GetSupportDirectory() + "/output-file-map.json";
+ cmStrCat(this->GeneratorTarget->GetSupportDirectory(), '/', config, '/',
+ "output-file-map.json");
std::string const targetSwiftDepsPath = [this, config]() -> std::string {
cmGeneratorTarget const* target = this->GeneratorTarget;
if (const char* name = target->GetProperty("Swift_DEPENDENCIES_FILE")) {
diff --git a/Tests/RunCMake/Swift/L.swift b/Tests/RunCMake/Swift/L.swift
new file mode 100644
index 0000000000..79ff87eafc
--- /dev/null
+++ b/Tests/RunCMake/Swift/L.swift
@@ -0,0 +1 @@
+public let ThirtyTwo: Int = 32
diff --git a/Tests/RunCMake/Swift/RunCMakeTest.cmake b/Tests/RunCMake/Swift/RunCMakeTest.cmake
index 918df0bed8..1db202e881 100644
--- a/Tests/RunCMake/Swift/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Swift/RunCMakeTest.cmake
@@ -12,6 +12,12 @@ elseif(RunCMake_GENERATOR STREQUAL Ninja)
run_cmake(SwiftMultiArch)
unset(RunCMake_TEST_OPTIONS)
endif()
+elseif(RunCMake_GENERATOR STREQUAL "Ninja Multi-Config")
+ if(CMAKE_Swift_COMPILER)
+ set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release")
+ run_cmake(SwiftSimple)
+ unset(RunCMake_TEST_OPTIONS)
+ endif()
else()
run_cmake(NotSupported)
endif()
diff --git a/Tests/RunCMake/Swift/SwiftSimple.cmake b/Tests/RunCMake/Swift/SwiftSimple.cmake
new file mode 100644
index 0000000000..1f2702d665
--- /dev/null
+++ b/Tests/RunCMake/Swift/SwiftSimple.cmake
@@ -0,0 +1,2 @@
+enable_language(Swift)
+add_library(L L.swift)