summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-06-21 13:25:09 (GMT)
committerBrad King <brad.king@kitware.com>2024-06-21 14:51:21 (GMT)
commit48b911e3e58089932c5d65bffc02ee66fac7f9b1 (patch)
treeb27b401e3544a3f14d0744a5198176ed693a434e /Source
parente2c6a54b076ad6050b38569a494bc1d82f0376e9 (diff)
downloadCMake-48b911e3e58089932c5d65bffc02ee66fac7f9b1.zip
CMake-48b911e3e58089932c5d65bffc02ee66fac7f9b1.tar.gz
CMake-48b911e3e58089932c5d65bffc02ee66fac7f9b1.tar.bz2
cmGlobalNinjaGenerator: Factor out helper for global config list lookup
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx47
-rw-r--r--Source/cmGlobalNinjaGenerator.h2
2 files changed, 22 insertions, 27 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 73bfb85..c50ef00 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -603,6 +603,12 @@ cmDocumentationEntry cmGlobalNinjaGenerator::GetDocumentation()
"Generates build.ninja files." };
}
+std::vector<std::string> cmGlobalNinjaGenerator::GetConfigNames() const
+{
+ return this->Makefiles.front()->GetGeneratorConfigs(
+ cmMakefile::IncludeEmptyConfig);
+}
+
// Implemented in all cmGlobaleGenerator sub-classes.
// Used in:
// Source/cmLocalGenerator.cxx
@@ -655,8 +661,7 @@ void cmGlobalNinjaGenerator::Generate()
if (cmSystemTools::GetErrorOccurredFlag()) {
this->RulesFileStream->setstate(std::ios::failbit);
- for (auto const& config : this->Makefiles[0]->GetGeneratorConfigs(
- cmMakefile::IncludeEmptyConfig)) {
+ for (std::string const& config : this->GetConfigNames()) {
this->GetImplFileStream(config)->setstate(std::ios::failbit);
this->GetConfigFileStream(config)->setstate(std::ios::failbit);
}
@@ -1491,9 +1496,7 @@ void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias,
for (std::string const& output : outputs) {
this->TargetAliases[output].GeneratorTarget = nullptr;
this->DefaultTargetAliases[output].GeneratorTarget = nullptr;
- for (const std::string& config2 :
- this->Makefiles.front()->GetGeneratorConfigs(
- cmMakefile::IncludeEmptyConfig)) {
+ for (std::string const& config2 : this->GetConfigNames()) {
this->Configs[config2].TargetAliases[output].GeneratorTarget = nullptr;
}
}
@@ -1567,8 +1570,7 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os)
}
if (this->IsMultiConfig()) {
- for (auto const& config : this->Makefiles.front()->GetGeneratorConfigs(
- cmMakefile::IncludeEmptyConfig)) {
+ for (std::string const& config : this->GetConfigNames()) {
for (auto const& ta : this->Configs[config].TargetAliases) {
// Don't write ambiguous aliases.
if (!ta.second.GeneratorTarget) {
@@ -1827,8 +1829,7 @@ void cmGlobalNinjaGenerator::WriteBuiltinTargets(std::ostream& os)
this->WriteTargetClean(os);
this->WriteTargetHelp(os);
- for (auto const& config : this->Makefiles[0]->GetGeneratorConfigs(
- cmMakefile::IncludeEmptyConfig)) {
+ for (std::string const& config : this->GetConfigNames()) {
this->WriteTargetDefault(*this->GetConfigFileStream(config));
}
@@ -2025,8 +2026,7 @@ bool cmGlobalNinjaGenerator::WriteTargetCleanAdditional(std::ostream& os)
std::string cleanScriptRel = "CMakeFiles/clean_additional.cmake";
std::string cleanScriptAbs =
cmStrCat(lgr->GetBinaryDirectory(), '/', cleanScriptRel);
- std::vector<std::string> configs =
- this->Makefiles[0]->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
+ std::vector<std::string> const& configs = this->GetConfigNames();
// Check if there are additional files to clean
bool empty = true;
@@ -2121,16 +2121,13 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
WriteRule(*this->RulesFileStream, rule);
}
- auto const configs = this->Makefiles.front()->GetGeneratorConfigs(
- cmMakefile::IncludeEmptyConfig);
-
// Write build
{
cmNinjaBuild build("CLEAN");
build.Comment = "Clean all the built files.";
build.Outputs.emplace_back();
- for (auto const& config : configs) {
+ for (std::string const& config : this->GetConfigNames()) {
build.Outputs.front() = this->BuildAlias(
this->NinjaOutputPath(this->GetCleanTargetName()), config);
if (this->IsMultiConfig()) {
@@ -2145,7 +2142,7 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
this->NinjaOutputPath(this->GetAdditionalCleanTargetName()),
config));
}
- for (auto const& fileConfig : configs) {
+ for (std::string const& fileConfig : this->GetConfigNames()) {
if (fileConfig != config && !this->EnableCrossConfigBuild()) {
continue;
}
@@ -2181,7 +2178,7 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
byproducts.emplace_back(GetByproductsForCleanTargetName());
build.Variables["TARGETS"] = cmJoin(byproducts, " ");
- for (auto const& fileConfig : configs) {
+ for (std::string const& fileConfig : this->GetConfigNames()) {
build.Variables["FILE_ARG"] = cmStrCat(
"-f ",
this->NinjaOutputPath(
@@ -2197,7 +2194,7 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
this->NinjaOutputPath(this->GetCleanTargetName()));
build.ExplicitDeps.emplace_back();
- for (auto const& config : configs) {
+ for (std::string const& config : this->GetConfigNames()) {
build.ExplicitDeps.front() = this->BuildAlias(
this->NinjaOutputPath(this->GetCleanTargetName()), config);
this->WriteBuild(*this->GetConfigFileStream(config), build);
@@ -2222,7 +2219,7 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
build.ExplicitDeps = this->ByproductsForCleanTarget;
this->WriteBuild(os, build);
- for (auto const& config : configs) {
+ for (std::string const& config : this->GetConfigNames()) {
build.Outputs.front() = this->BuildAlias(
this->ConvertToNinjaPath(GetByproductsForCleanTargetName()), config);
build.ExplicitDeps = this->Configs[config].ByproductsForCleanTarget;
@@ -3119,8 +3116,7 @@ bool cmGlobalNinjaMultiGenerator::OpenBuildFileStreams()
<< "# This file contains build statements common to all "
"configurations.\n\n";
- auto const& configs =
- this->Makefiles[0]->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
+ std::vector<std::string> const& configs = this->GetConfigNames();
return std::all_of(
configs.begin(), configs.end(), [this](std::string const& config) -> bool {
// Open impl file.
@@ -3163,8 +3159,7 @@ void cmGlobalNinjaMultiGenerator::CloseBuildFileStreams()
this->DefaultFileStream.reset();
} // No error if it wasn't open
- for (auto const& config : this->Makefiles[0]->GetGeneratorConfigs(
- cmMakefile::IncludeEmptyConfig)) {
+ for (std::string const& config : this->GetConfigNames()) {
if (this->ImplFileStreams[config]) {
this->ImplFileStreams[config].reset();
} else {
@@ -3206,8 +3201,7 @@ std::string cmGlobalNinjaMultiGenerator::GetNinjaConfigFilename(
void cmGlobalNinjaMultiGenerator::AddRebuildManifestOutputs(
cmNinjaDeps& outputs) const
{
- for (auto const& config : this->Makefiles.front()->GetGeneratorConfigs(
- cmMakefile::IncludeEmptyConfig)) {
+ for (std::string const& config : this->GetConfigNames()) {
outputs.push_back(this->NinjaOutputPath(GetNinjaImplFilename(config)));
outputs.push_back(this->NinjaOutputPath(GetNinjaConfigFilename(config)));
}
@@ -3219,8 +3213,7 @@ void cmGlobalNinjaMultiGenerator::AddRebuildManifestOutputs(
void cmGlobalNinjaMultiGenerator::GetQtAutoGenConfigs(
std::vector<std::string>& configs) const
{
- auto allConfigs =
- this->Makefiles[0]->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
+ std::vector<std::string> const& allConfigs = this->GetConfigNames();
configs.insert(configs.end(), cm::cbegin(allConfigs), cm::cend(allConfigs));
}
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 9758627..7c7b356 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -485,6 +485,8 @@ public:
bool CheckCxxModuleSupport(CxxModuleSupportQuery query) override;
protected:
+ std::vector<std::string> GetConfigNames() const;
+
void Generate() override;
bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const override { return true; }