summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalNinjaGenerator.cxx
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2020-01-17 21:00:28 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2020-01-22 15:26:21 (GMT)
commit8337ed0d731f869823efcacf2460a4efbf74a991 (patch)
treecaf2baf60879268e6725235e43c28ea35aeaf0e9 /Source/cmGlobalNinjaGenerator.cxx
parent110037369d9be6c346f3de5074bb2e4d47c7e36c (diff)
downloadCMake-8337ed0d731f869823efcacf2460a4efbf74a991.zip
CMake-8337ed0d731f869823efcacf2460a4efbf74a991.tar.gz
CMake-8337ed0d731f869823efcacf2460a4efbf74a991.tar.bz2
Ninja Multi-Config: Add variable to control aliases in build.ninja
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx44
1 files changed, 31 insertions, 13 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 28b1cb4..0911cd0 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -1161,14 +1161,11 @@ void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias,
newAliasGlobal.first->second.GeneratorTarget != target) {
newAliasGlobal.first->second.GeneratorTarget = nullptr;
}
- if (config != "all") {
- std::pair<TargetAliasMap::iterator, bool> newAliasConfig =
- this->Configs[config].TargetAliases.insert(
- std::make_pair(outputPath, ta));
- if (newAliasConfig.second &&
- newAliasConfig.first->second.GeneratorTarget != target) {
- newAliasConfig.first->second.GeneratorTarget = nullptr;
- }
+ std::pair<TargetAliasMap::iterator, bool> newAliasConfig =
+ this->Configs[config].TargetAliases.insert(std::make_pair(outputPath, ta));
+ if (newAliasConfig.second &&
+ newAliasConfig.first->second.GeneratorTarget != target) {
+ newAliasConfig.first->second.GeneratorTarget = nullptr;
}
}
@@ -1231,7 +1228,7 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os)
}
}
- auto const* defaultConfig = this->GetDefaultBuildType();
+ auto const* defaultConfig = this->GetDefaultBuildAlias();
if (defaultConfig) {
std::string config = defaultConfig;
for (auto const& ta : this->Configs[config].TargetAliases) {
@@ -1248,8 +1245,16 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os)
build.Outputs.front() = ta.first;
build.ExplicitDeps.clear();
- this->AppendTargetOutputs(ta.second.GeneratorTarget,
- build.ExplicitDeps, config);
+ if (config == "all") {
+ for (auto const& config2 :
+ this->Makefiles.front()->GetGeneratorConfigs()) {
+ this->AppendTargetOutputs(ta.second.GeneratorTarget,
+ build.ExplicitDeps, config2);
+ }
+ } else {
+ this->AppendTargetOutputs(ta.second.GeneratorTarget,
+ build.ExplicitDeps, config);
+ }
this->WriteBuild(*this->GetDefaultFileStream(), build);
}
}
@@ -1311,7 +1316,7 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os)
this->WriteBuild(*this->GetConfigFileStream(config), build);
}
- auto const* defaultConfig = this->GetDefaultBuildType();
+ auto const* defaultConfig = this->GetDefaultBuildAlias();
if (defaultConfig) {
std::string config = defaultConfig;
build.ExplicitDeps = { this->BuildAlias(
@@ -1807,7 +1812,7 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
this->WriteBuild(*this->GetConfigFileStream(config), build);
}
- auto const* defaultConfig = this->GetDefaultBuildType();
+ auto const* defaultConfig = this->GetDefaultBuildAlias();
if (defaultConfig) {
std::string config = defaultConfig;
build.ExplicitDeps.front() = this->BuildAlias(
@@ -2507,3 +2512,16 @@ const char* cmGlobalNinjaMultiGenerator::GetDefaultBuildType() const
return this->Makefiles.front()->GetDefinition(
"CMAKE_NINJA_MULTI_DEFAULT_BUILD_TYPE");
}
+
+const char* cmGlobalNinjaMultiGenerator::GetDefaultBuildAlias() const
+{
+ if (this->EnableCrossConfigBuild()) {
+ auto const* alias = this->Makefiles.front()->GetDefinition(
+ "CMAKE_NINJA_MULTI_DEFAULT_BUILD_ALIAS");
+ if (alias) {
+ return alias;
+ }
+ }
+
+ return this->GetDefaultBuildType();
+}