Swift: support Ninja Multi-Config

Enable support for multi-configuration builds using Ninja when building
Swift.
This commit is contained in:
Saleem Abdulrasool 2020-03-07 10:15:29 -08:00 committed by Kyle Edwards
parent 6857aaaa06
commit 65b3848de0
6 changed files with 15 additions and 5 deletions

View File

@ -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()

View File

@ -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;

View File

@ -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")) {

View File

@ -0,0 +1 @@
public let ThirtyTwo: Int = 32

View File

@ -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()

View File

@ -0,0 +1,2 @@
enable_language(Swift)
add_library(L L.swift)