diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2020-01-23 19:46:16 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2020-01-23 20:47:12 (GMT) |
commit | b7a2baf38c1f481f31db9ab41fc129a970287efd (patch) | |
tree | 946c797459ed2801bc808623f3c62852e4ff9018 /Source/cmGlobalNinjaGenerator.cxx | |
parent | ab2fc918216011a03f0fe7696e7bba67fc2627b3 (diff) | |
download | CMake-b7a2baf38c1f481f31db9ab41fc129a970287efd.zip CMake-b7a2baf38c1f481f31db9ab41fc129a970287efd.tar.gz CMake-b7a2baf38c1f481f31db9ab41fc129a970287efd.tar.bz2 |
Ninja Multi-Config: Add variable to control configs used in cross-config build
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 62 |
1 files changed, 52 insertions, 10 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 0911cd0..020d2af 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1191,8 +1191,7 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os) build.Outputs.front() = ta.first; build.ExplicitDeps.clear(); if (ta.second.Config == "all") { - for (auto const& config : - ta.second.GeneratorTarget->Makefile->GetGeneratorConfigs()) { + for (auto const& config : this->GetCrossConfigs("")) { this->AppendTargetOutputs(ta.second.GeneratorTarget, build.ExplicitDeps, config); } @@ -1200,7 +1199,9 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os) this->AppendTargetOutputs(ta.second.GeneratorTarget, build.ExplicitDeps, ta.second.Config); } - this->WriteBuild(this->EnableCrossConfigBuild() + this->WriteBuild(this->EnableCrossConfigBuild() && + (ta.second.Config == "all" || + this->GetCrossConfigs("").count(ta.second.Config)) ? os : *this->GetImplFileStream(ta.second.Config), build); @@ -1301,9 +1302,11 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os) } } // Write target - this->WriteBuild( - this->EnableCrossConfigBuild() ? os : *this->GetImplFileStream(config), - build); + this->WriteBuild(this->EnableCrossConfigBuild() && + this->GetCrossConfigs("").count(config) + ? os + : *this->GetImplFileStream(config), + build); } // Add shortcut target @@ -1330,7 +1333,7 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os) // Add target for all configs if (this->EnableCrossConfigBuild()) { build.ExplicitDeps.clear(); - for (auto const& config : configs) { + for (auto const& config : this->GetCrossConfigs("")) { build.ExplicitDeps.push_back(this->BuildAlias( this->ConvertToNinjaPath(currentBinaryDir + "/all"), config)); } @@ -1785,11 +1788,19 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) build.ExplicitDeps.clear(); if (additionalFiles) { - build.ExplicitDeps.push_back( - this->NinjaOutputPath(this->GetAdditionalCleanTargetName())); + for (auto const& config : this->GetCrossConfigs("")) { + build.ExplicitDeps.push_back(this->BuildAlias( + this->NinjaOutputPath(this->GetAdditionalCleanTargetName()), + config)); + } } - build.Variables["TARGETS"] = ""; + std::vector<std::string> byproducts; + for (auto const& config : this->GetCrossConfigs("")) { + byproducts.push_back( + this->BuildAlias(GetByproductsForCleanTargetName(), config)); + } + build.Variables["TARGETS"] = cmJoin(byproducts, " "); for (auto const& fileConfig : configs) { build.Variables["FILE_ARG"] = cmStrCat( @@ -2359,6 +2370,15 @@ void cmGlobalNinjaGenerator::AppendDirectoryForConfig( } } +std::set<std::string> cmGlobalNinjaGenerator::GetCrossConfigs( + const std::string& /*fileConfig*/) const +{ + std::set<std::string> result; + result.insert( + this->Makefiles.front()->GetSafeDefinition("CMAKE_BUILD_TYPE")); + return result; +} + const char* cmGlobalNinjaMultiGenerator::NINJA_COMMON_FILE = "CMakeFiles/common.ninja"; const char* cmGlobalNinjaMultiGenerator::NINJA_FILE_EXTENSION = ".ninja"; @@ -2525,3 +2545,25 @@ const char* cmGlobalNinjaMultiGenerator::GetDefaultBuildAlias() const return this->GetDefaultBuildType(); } + +std::set<std::string> cmGlobalNinjaMultiGenerator::GetCrossConfigs( + const std::string& fileConfig) const +{ + std::vector<std::string> configs; + if (this->EnableCrossConfigBuild()) { + auto configsValue = this->Makefiles.front()->GetSafeDefinition( + "CMAKE_NINJA_MULTI_CROSS_CONFIGS"); + if (!configsValue.empty()) { + cmExpandList(configsValue, configs); + } else { + configs = this->Makefiles.front()->GetGeneratorConfigs(); + } + } + + std::set<std::string> result(configs.cbegin(), configs.cend()); + if (!fileConfig.empty()) { + result.insert(fileConfig); + } + + return result; +} |