From 10507c6dc0918777d43b3f961bd18162866f0bbb Mon Sep 17 00:00:00 2001 From: Daniel Eiband Date: Fri, 30 Aug 2019 11:47:37 +0200 Subject: cmMakefile: Add configurations getter with empty configuration default --- Source/cmComputeTargetDepends.cxx | 7 ++----- Source/cmFileAPICodemodel.cxx | 13 +++++-------- Source/cmGeneratorTarget.cxx | 28 ++++++++-------------------- Source/cmGlobalGenerator.cxx | 15 ++++----------- Source/cmLocalGenerator.cxx | 7 ++----- Source/cmMakefile.cxx | 10 ++++++++++ Source/cmMakefile.h | 3 +++ 7 files changed, 34 insertions(+), 49 deletions(-) diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 01d4c07..6bf2f2d 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -197,11 +197,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) { std::set emitted; - std::vector configs; - depender->Makefile->GetConfigurations(configs); - if (configs.empty()) { - configs.emplace_back(); - } + std::vector const& configs = + depender->Makefile->GetGeneratorConfigs(); for (std::string const& it : configs) { std::vector objectFiles; depender->GetExternalObjects(objectFiles, it); diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 08db7c7..db6d675 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -423,20 +423,17 @@ Json::Value Codemodel::DumpPaths() Json::Value Codemodel::DumpConfigurations() { - std::vector configs; + Json::Value configurations = Json::arrayValue; cmGlobalGenerator* gg = this->FileAPI.GetCMakeInstance()->GetGlobalGenerator(); auto makefiles = gg->GetMakefiles(); if (!makefiles.empty()) { - makefiles[0]->GetConfigurations(configs); - if (configs.empty()) { - configs.emplace_back(); + std::vector const& configs = + makefiles[0]->GetGeneratorConfigs(); + for (std::string const& config : configs) { + configurations.append(this->DumpConfiguration(config)); } } - Json::Value configurations = Json::arrayValue; - for (std::string const& config : configs) { - configurations.append(this->DumpConfiguration(config)); - } return configurations; } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index cc37232..6de7d83 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -786,11 +786,8 @@ void cmGeneratorTarget::ComputeObjectMapping() return; } - std::vector configs; - this->Makefile->GetConfigurations(configs); - if (configs.empty()) { - configs.emplace_back(); - } + std::vector const& configs = + this->Makefile->GetGeneratorConfigs(); for (std::string const& c : configs) { std::vector sourceFiles; this->GetObjectSources(sourceFiles, c); @@ -2634,12 +2631,9 @@ cmTargetTraceDependencies::cmTargetTraceDependencies(cmGeneratorTarget* target) // Queue all the source files already specified for the target. if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { - std::vector configs; - this->Makefile->GetConfigurations(configs); - if (configs.empty()) { - configs.emplace_back(); - } std::set emitted; + std::vector const& configs = + this->Makefile->GetGeneratorConfigs(); for (std::string const& c : configs) { std::vector sources; this->GeneratorTarget->GetSourceFiles(sources, c); @@ -2825,12 +2819,9 @@ void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc) } // Queue the custom command dependencies. - std::vector configs; std::set emitted; - this->Makefile->GetConfigurations(configs); - if (configs.empty()) { - configs.emplace_back(); - } + std::vector const& configs = + this->Makefile->GetGeneratorConfigs(); for (std::string const& conf : configs) { this->FollowCommandDepends(cc, conf, emitted); } @@ -6077,11 +6068,8 @@ const cmLinkImplementation* cmGeneratorTarget::GetLinkImplementation( bool cmGeneratorTarget::GetConfigCommonSourceFiles( std::vector& files) const { - std::vector configs; - this->Makefile->GetConfigurations(configs); - if (configs.empty()) { - configs.emplace_back(); - } + std::vector const& configs = + this->Makefile->GetGeneratorConfigs(); std::vector::const_iterator it = configs.begin(); const std::string& firstConfig = *it; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 4342e9f..53ed535 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -337,12 +337,8 @@ bool cmGlobalGenerator::CheckTargetsForType() const for (cmGeneratorTarget* target : generator->GetGeneratorTargets()) { if (target->GetType() == cmStateEnums::EXECUTABLE && target->GetPropertyAsBool("WIN32_EXECUTABLE")) { - std::vector configs; - target->Makefile->GetConfigurations(configs); - if (configs.empty()) { - configs.emplace_back(); - } - + std::vector const& configs = + target->Makefile->GetGeneratorConfigs(); for (std::string const& config : configs) { if (target->GetLinkerLanguage(config) == "Swift") { this->GetCMakeInstance()->IssueMessage( @@ -2963,11 +2959,8 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) // List the source files with any per-source labels. fout << "# Source files and their labels\n"; std::vector sources; - std::vector configs; - target->Target->GetMakefile()->GetConfigurations(configs); - if (configs.empty()) { - configs.emplace_back(); - } + std::vector const& configs = + target->Target->GetMakefile()->GetGeneratorConfigs(); for (std::string const& c : configs) { target->GetSourceFiles(sources, c); } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 7177694..155e5b8 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -257,11 +257,8 @@ static void MoveSystemIncludesToEnd(std::vector>& includeDirs, void cmLocalGenerator::TraceDependencies() { - std::vector configs; - this->Makefile->GetConfigurations(configs); - if (configs.empty()) { - configs.emplace_back(); - } + std::vector const& configs = + this->Makefile->GetGeneratorConfigs(); for (std::string const& c : configs) { this->GlobalGenerator->CreateEvaluationSourceFiles(c); } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f101cdc..e65d264 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3057,6 +3057,16 @@ std::string cmMakefile::GetConfigurations(std::vector& configs, return buildType; } +std::vector cmMakefile::GetGeneratorConfigs() const +{ + std::vector configs; + GetConfigurations(configs); + if (configs.empty()) { + configs.emplace_back(); + } + return configs; +} + bool cmMakefile::IsFunctionBlocked(const cmListFileFunction& lff, cmExecutionStatus& status) { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index dcc4e77..6b9fa6b 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -292,6 +292,9 @@ public: std::string GetConfigurations(std::vector& configs, bool single = true) const; + /** Get the configurations for dependency checking. */ + std::vector GetGeneratorConfigs() const; + /** * Set the name of the library. */ -- cgit v0.12