From 7a969fe21d736b6c6755b5dc7a105f1427242cdd Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 30 Jun 2020 13:44:37 -0400 Subject: cmMakefile: Refactor API to better handle empty config values --- Source/cmComputeTargetDepends.cxx | 2 +- Source/cmExportCommand.cxx | 8 ++--- Source/cmExportFileGenerator.cxx | 5 +-- Source/cmFileAPICodemodel.cxx | 2 +- Source/cmGeneratorExpressionEvaluationFile.cxx | 8 ++--- Source/cmGeneratorTarget.cxx | 13 +++---- Source/cmGlobalGenerator.cxx | 32 ++++++++--------- Source/cmGlobalNinjaGenerator.cxx | 49 +++++++++++++------------- Source/cmGlobalVisualStudio71Generator.cxx | 4 +-- Source/cmGlobalVisualStudio7Generator.cxx | 5 +-- Source/cmGlobalXCodeGenerator.cxx | 7 ++-- Source/cmJsonObjects.cxx | 6 +--- Source/cmLinkItemGraphVisitor.cxx | 3 +- Source/cmLocalCommonGenerator.cxx | 6 ++-- Source/cmLocalGenerator.cxx | 35 +++++++----------- Source/cmLocalVisualStudio7Generator.cxx | 9 ++--- Source/cmMakefile.cxx | 31 ++++++++-------- Source/cmMakefile.h | 15 +++++--- Source/cmNinjaTargetGenerator.cxx | 3 +- Source/cmQtAutoGenInitializer.cxx | 7 ++-- Source/cmTarget.cxx | 4 +-- Source/cmVisualStudio10TargetGenerator.cxx | 3 +- 22 files changed, 125 insertions(+), 132 deletions(-) diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 41f5346..6b4d110 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -196,7 +196,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) std::set emitted; std::vector const& configs = - depender->Makefile->GetGeneratorConfigs(); + depender->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); for (std::string const& it : configs) { cmLinkImplementation const* impl = depender->GetLinkImplementation(it); diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index 9f8a821..352eaf2 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -223,11 +223,9 @@ bool cmExportCommand(std::vector const& args, ebfg->SetExportOld(arguments.ExportOld); // Compute the set of configurations exported. - std::vector configurationTypes; - mf.GetConfigurations(configurationTypes); - if (configurationTypes.empty()) { - configurationTypes.emplace_back(); - } + std::vector configurationTypes = + mf.GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); + for (std::string const& ct : configurationTypes) { ebfg->AddConfiguration(ct); } diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 4d0e099..58aa391 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -567,8 +567,9 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( if (gtarget->GetType() != cmStateEnums::INTERFACE_LIBRARY) { getCompatibleInterfaceProperties(gtarget, ifaceProperties, ""); - std::vector configNames; - gtarget->Target->GetMakefile()->GetConfigurations(configNames); + std::vector configNames = + gtarget->Target->GetMakefile()->GetGeneratorConfigs( + cmMakefile::ExcludeEmptyConfig); for (std::string const& cn : configNames) { getCompatibleInterfaceProperties(gtarget, ifaceProperties, cn); diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 21d9abb..ca1ed56 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -445,7 +445,7 @@ Json::Value Codemodel::DumpConfigurations() const auto& makefiles = gg->GetMakefiles(); if (!makefiles.empty()) { std::vector const& configs = - makefiles[0]->GetGeneratorConfigs(); + makefiles[0]->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); for (std::string const& config : configs) { configurations.append(this->DumpConfiguration(config)); } diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index 9e8707d..1107adb 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -157,12 +157,8 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg) std::map outputFiles; - std::vector allConfigs; - lg->GetMakefile()->GetConfigurations(allConfigs); - - if (allConfigs.empty()) { - allConfigs.emplace_back(); - } + std::vector allConfigs = + lg->GetMakefile()->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); std::vector enabledLanguages; cmGlobalGenerator* gg = lg->GetGlobalGenerator(); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 992682f..962d97f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -801,7 +801,8 @@ void cmGeneratorTarget::GetObjectSources( void cmGeneratorTarget::ComputeObjectMapping() { - auto const& configs = this->Makefile->GetGeneratorConfigs(); + auto const& configs = + this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); std::set configSet(configs.begin(), configs.end()); if (configSet == this->VisitedConfigsForObjects) { return; @@ -1778,8 +1779,8 @@ cmGeneratorTarget::GetAllConfigSources() const void cmGeneratorTarget::ComputeAllConfigSources() const { - std::vector configs; - this->Makefile->GetConfigurations(configs); + std::vector configs = + this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); std::map index; @@ -2812,7 +2813,7 @@ cmTargetTraceDependencies::cmTargetTraceDependencies(cmGeneratorTarget* target) if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { std::set emitted; std::vector const& configs = - this->Makefile->GetGeneratorConfigs(); + this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); for (std::string const& c : configs) { std::vector sources; this->GeneratorTarget->GetSourceFiles(sources, c); @@ -3023,7 +3024,7 @@ void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc) // Queue the custom command dependencies. std::set emitted; std::vector const& configs = - this->Makefile->GetGeneratorConfigs(); + this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); for (std::string const& conf : configs) { this->FollowCommandDepends(cc, conf, emitted); } @@ -6843,7 +6844,7 @@ bool cmGeneratorTarget::GetConfigCommonSourceFiles( std::vector& files) const { std::vector const& configs = - this->Makefile->GetGeneratorConfigs(); + this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); auto it = configs.begin(); const std::string& firstConfig = *it; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 6001999..a0cee0e 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -313,19 +313,16 @@ bool cmGlobalGenerator::CheckTargetsForMissingSources() const } } - std::vector configs; - target->Makefile->GetConfigurations(configs); + std::vector configs = + target->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); std::vector srcs; - if (configs.empty()) { - target->GetSourceFiles(srcs, ""); - } else { - for (std::string const& config : configs) { - target->GetSourceFiles(srcs, config); - if (!srcs.empty()) { - break; - } + for (std::string const& config : configs) { + target->GetSourceFiles(srcs, config); + if (!srcs.empty()) { + break; } } + if (srcs.empty()) { std::ostringstream e; e << "No SOURCES given to target: " << target->GetName(); @@ -349,7 +346,8 @@ bool cmGlobalGenerator::CheckTargetsForType() const if (target->GetType() == cmStateEnums::EXECUTABLE && target->GetPropertyAsBool("WIN32_EXECUTABLE")) { std::vector const& configs = - target->Makefile->GetGeneratorConfigs(); + target->Makefile->GetGeneratorConfigs( + cmMakefile::IncludeEmptyConfig); for (std::string const& config : configs) { if (target->GetLinkerLanguage(config) == "Swift") { this->GetCMakeInstance()->IssueMessage( @@ -1701,8 +1699,8 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo() cmPolicies::PolicyStatus polSt = mf->GetPolicyStatus(cmPolicies::CMP0043); if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) { - std::vector configs; - mf->GetConfigurations(configs); + std::vector configs = + mf->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig); for (std::string const& c : configs) { std::string defPropName = @@ -3127,7 +3125,8 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) fout << "# Source files and their labels\n"; std::vector sources; std::vector const& configs = - target->Target->GetMakefile()->GetGeneratorConfigs(); + target->Target->GetMakefile()->GetGeneratorConfigs( + cmMakefile::IncludeEmptyConfig); for (std::string const& c : configs) { target->GetSourceFiles(sources, c); } @@ -3226,8 +3225,9 @@ bool cmGlobalGenerator::GenerateCPackPropertiesFile() const auto& lg = this->LocalGenerators[0]; cmMakefile* mf = lg->GetMakefile(); - std::vector configs; - std::string config = mf->GetConfigurations(configs, false); + std::vector configs = + mf->GetGeneratorConfigs(cmMakefile::OnlyMultiConfig); + std::string config = mf->GetDefaultConfiguration(); std::string path = cmStrCat(this->CMakeInstance->GetHomeOutputDirectory(), "/CPackProperties.cmake"); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 843b0f4..48eb405 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -5,9 +5,9 @@ #include #include #include -#include #include +#include #include #include #include @@ -518,7 +518,8 @@ void cmGlobalNinjaGenerator::Generate() if (cmSystemTools::GetErrorOccuredFlag()) { this->RulesFileStream->setstate(std::ios::failbit); - for (auto const& config : this->Makefiles[0]->GetGeneratorConfigs()) { + for (auto const& config : this->Makefiles[0]->GetGeneratorConfigs( + cmMakefile::IncludeEmptyConfig)) { this->GetImplFileStream(config)->setstate(std::ios::failbit); this->GetConfigFileStream(config)->setstate(std::ios::failbit); } @@ -1207,7 +1208,8 @@ void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias, this->TargetAliases[output].GeneratorTarget = nullptr; this->DefaultTargetAliases[output].GeneratorTarget = nullptr; for (const std::string& config2 : - this->Makefiles.front()->GetGeneratorConfigs()) { + this->Makefiles.front()->GetGeneratorConfigs( + cmMakefile::IncludeEmptyConfig)) { this->Configs[config2].TargetAliases[output].GeneratorTarget = nullptr; } } @@ -1280,7 +1282,8 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os) } if (this->IsMultiConfig()) { - for (auto const& config : this->Makefiles.front()->GetGeneratorConfigs()) { + for (auto const& config : this->Makefiles.front()->GetGeneratorConfigs( + cmMakefile::IncludeEmptyConfig)) { for (auto const& ta : this->Configs[config].TargetAliases) { // Don't write ambiguous aliases. if (!ta.second.GeneratorTarget) { @@ -1339,11 +1342,9 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os) cmGlobalNinjaGenerator::WriteDivider(os); std::string const& currentBinaryDir = it.first; DirectoryTarget const& dt = it.second; - std::vector configs; - dt.LG->GetMakefile()->GetConfigurations(configs, true); - if (configs.empty()) { - configs.emplace_back(); - } + std::vector configs = + dt.LG->GetMakefile()->GetGeneratorConfigs( + cmMakefile::IncludeEmptyConfig); // Setup target cmNinjaDeps configDeps; @@ -1538,7 +1539,8 @@ void cmGlobalNinjaGenerator::WriteBuiltinTargets(std::ostream& os) this->WriteTargetClean(os); this->WriteTargetHelp(os); - for (auto const& config : this->Makefiles[0]->GetGeneratorConfigs()) { + for (auto const& config : this->Makefiles[0]->GetGeneratorConfigs( + cmMakefile::IncludeEmptyConfig)) { this->WriteTargetDefault(*this->GetConfigFileStream(config)); } @@ -1712,11 +1714,8 @@ bool cmGlobalNinjaGenerator::WriteTargetCleanAdditional(std::ostream& os) std::string cleanScriptRel = "CMakeFiles/clean_additional.cmake"; std::string cleanScriptAbs = cmStrCat(lgr->GetBinaryDirectory(), '/', cleanScriptRel); - std::vector configs; - this->Makefiles[0]->GetConfigurations(configs, true); - if (configs.empty()) { - configs.emplace_back(); - } + std::vector configs = + this->Makefiles[0]->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); // Check if there are additional files to clean bool empty = true; @@ -1810,7 +1809,8 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) WriteRule(*this->RulesFileStream, rule); } - auto const configs = this->Makefiles.front()->GetGeneratorConfigs(); + auto const configs = this->Makefiles.front()->GetGeneratorConfigs( + cmMakefile::IncludeEmptyConfig); // Write build { @@ -2489,7 +2489,8 @@ bool cmGlobalNinjaMultiGenerator::OpenBuildFileStreams() << "# This file contains build statements common to all " "configurations.\n\n"; - for (auto const& config : this->Makefiles[0]->GetGeneratorConfigs()) { + for (auto const& config : this->Makefiles[0]->GetGeneratorConfigs( + cmMakefile::IncludeEmptyConfig)) { // Open impl file. if (!this->OpenFileStream(this->ImplFileStreams[config], GetNinjaImplFilename(config))) { @@ -2529,7 +2530,8 @@ void cmGlobalNinjaMultiGenerator::CloseBuildFileStreams() this->DefaultFileStream.reset(); } // No error if it wasn't open - for (auto const& config : this->Makefiles[0]->GetGeneratorConfigs()) { + for (auto const& config : this->Makefiles[0]->GetGeneratorConfigs( + cmMakefile::IncludeEmptyConfig)) { if (this->ImplFileStreams[config]) { this->ImplFileStreams[config].reset(); } else { @@ -2571,7 +2573,8 @@ std::string cmGlobalNinjaMultiGenerator::GetNinjaConfigFilename( void cmGlobalNinjaMultiGenerator::AddRebuildManifestOutputs( cmNinjaDeps& outputs) const { - for (auto const& config : this->Makefiles.front()->GetGeneratorConfigs()) { + for (auto const& config : this->Makefiles.front()->GetGeneratorConfigs( + cmMakefile::IncludeEmptyConfig)) { outputs.push_back(this->NinjaOutputPath(GetNinjaImplFilename(config))); outputs.push_back(this->NinjaOutputPath(GetNinjaConfigFilename(config))); } @@ -2583,11 +2586,9 @@ void cmGlobalNinjaMultiGenerator::AddRebuildManifestOutputs( void cmGlobalNinjaMultiGenerator::GetQtAutoGenConfigs( std::vector& configs) const { - auto const oldSize = configs.size(); - this->Makefiles.front()->GetConfigurations(configs); - if (configs.size() == oldSize) { - configs.emplace_back(); - } + auto allConfigs = + this->Makefiles[0]->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); + configs.insert(configs.end(), cm::cbegin(allConfigs), cm::cend(allConfigs)); } bool cmGlobalNinjaMultiGenerator::InspectConfigTypeVariables() diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 7ada325..0083c40 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -19,8 +19,8 @@ void cmGlobalVisualStudio71Generator::WriteSLNFile( std::ostream& fout, cmLocalGenerator* root, std::vector& generators) { - std::vector configs; - root->GetMakefile()->GetConfigurations(configs); + std::vector configs = + root->GetMakefile()->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig); // Write out the header for a SLN file this->WriteSLNHeader(fout); diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 428c748..9f798e6 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -568,8 +568,9 @@ void cmGlobalVisualStudio7Generator::WriteSLNFooter(std::ostream& fout) std::string cmGlobalVisualStudio7Generator::WriteUtilityDepend( cmGeneratorTarget const* target) { - std::vector configs; - target->Target->GetMakefile()->GetConfigurations(configs); + std::vector configs = + target->Target->GetMakefile()->GetGeneratorConfigs( + cmMakefile::ExcludeEmptyConfig); std::string pname = cmStrCat(target->GetName(), "_UTILITY"); std::string fname = cmStrCat(target->GetLocalGenerator()->GetCurrentBinaryDirectory(), '/', diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index bb422eb..67e795b 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1077,11 +1077,8 @@ void cmGlobalXCodeGenerator::SetCurrentLocalGenerator(cmLocalGenerator* gen) this->CurrentMakefile = gen->GetMakefile(); // Select the current set of configuration types. - this->CurrentConfigurationTypes.clear(); - this->CurrentMakefile->GetConfigurations(this->CurrentConfigurationTypes); - if (this->CurrentConfigurationTypes.empty()) { - this->CurrentConfigurationTypes.emplace_back(); - } + this->CurrentConfigurationTypes = + this->CurrentMakefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); } struct cmSourceFilePathCompare diff --git a/Source/cmJsonObjects.cxx b/Source/cmJsonObjects.cxx index 9f17f15..3a2e3be 100644 --- a/Source/cmJsonObjects.cxx +++ b/Source/cmJsonObjects.cxx @@ -51,11 +51,7 @@ std::vector getConfigurations(const cmake* cm) return configurations; } - makefiles[0]->GetConfigurations(configurations); - if (configurations.empty()) { - configurations.emplace_back(); - } - return configurations; + return makefiles[0]->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); } bool hasString(const Json::Value& v, const std::string& s) diff --git a/Source/cmLinkItemGraphVisitor.cxx b/Source/cmLinkItemGraphVisitor.cxx index b13def8..dfdd3ff 100644 --- a/Source/cmLinkItemGraphVisitor.cxx +++ b/Source/cmLinkItemGraphVisitor.cxx @@ -28,7 +28,8 @@ void cmLinkItemGraphVisitor::VisitLinks(cmLinkItem const& item, return; } - for (auto const& config : item.Target->Makefile->GetGeneratorConfigs()) { + for (auto const& config : item.Target->Makefile->GetGeneratorConfigs( + cmMakefile::IncludeEmptyConfig)) { this->VisitLinks(item, rootItem, config); } } diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx index 278ec8b..44db842 100644 --- a/Source/cmLocalCommonGenerator.cxx +++ b/Source/cmLocalCommonGenerator.cxx @@ -17,10 +17,8 @@ cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg, : cmLocalGenerator(gg, mf) , WorkingDirectory(std::move(wd)) { - this->Makefile->GetConfigurations(this->ConfigNames); - if (this->ConfigNames.empty()) { - this->ConfigNames.emplace_back(); - } + this->ConfigNames = + this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); } cmLocalCommonGenerator::~cmLocalCommonGenerator() = default; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 42a5780..1fa7c7b 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -297,9 +297,9 @@ void cmLocalGenerator::GenerateTestFiles() } // Compute the set of configurations. - std::vector configurationTypes; - const std::string& config = - this->Makefile->GetConfigurations(configurationTypes, false); + std::vector configurationTypes = + this->Makefile->GetGeneratorConfigs(cmMakefile::OnlyMultiConfig); + std::string config = this->Makefile->GetDefaultConfiguration(); std::string file = cmStrCat(this->StateSnapshot.GetDirectory().GetCurrentBinary(), @@ -379,7 +379,7 @@ void cmLocalGenerator::GenerateTestFiles() void cmLocalGenerator::CreateEvaluationFileOutputs() { std::vector const& configs = - this->Makefile->GetGeneratorConfigs(); + this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); for (std::string const& c : configs) { this->CreateEvaluationFileOutputs(c); } @@ -462,9 +462,9 @@ void cmLocalGenerator::GenerateInstallRules() } // Compute the set of configurations. - std::vector configurationTypes; - const std::string& config = - this->Makefile->GetConfigurations(configurationTypes, false); + std::vector configurationTypes = + this->Makefile->GetGeneratorConfigs(cmMakefile::OnlyMultiConfig); + std::string config = this->Makefile->GetDefaultConfiguration(); // Choose a default install configuration. std::string default_config = config; @@ -753,11 +753,8 @@ cmGeneratorTarget* cmLocalGenerator::FindLocalNonAliasGeneratorTarget( void cmLocalGenerator::ComputeTargetManifest() { // Collect the set of configuration types. - std::vector configNames; - this->Makefile->GetConfigurations(configNames); - if (configNames.empty()) { - configNames.emplace_back(); - } + std::vector configNames = + this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); // Add our targets to the manifest for each configuration. const auto& targets = this->GetGeneratorTargets(); @@ -774,11 +771,8 @@ void cmLocalGenerator::ComputeTargetManifest() bool cmLocalGenerator::ComputeTargetCompileFeatures() { // Collect the set of configuration types. - std::vector configNames; - this->Makefile->GetConfigurations(configNames); - if (configNames.empty()) { - configNames.emplace_back(); - } + std::vector configNames = + this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); using LanguagePair = std::pair; std::vector pairedLanguages{ { "OBJC", "C" }, @@ -2551,11 +2545,8 @@ void cmLocalGenerator::AppendFlagEscape(std::string& flags, void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target) { - std::vector configsList; - std::string configDefault = this->Makefile->GetConfigurations(configsList); - if (configsList.empty()) { - configsList.push_back(configDefault); - } + std::vector configsList = + this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); for (std::string const& config : configsList) { // FIXME: Refactor collection of sources to not evaluate object diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 5d50e2d..ad61ad3 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1331,8 +1331,8 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, const std::string& libName, cmGeneratorTarget* target) { - std::vector configs; - this->Makefile->GetConfigurations(configs); + std::vector configs = + this->Makefile->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig); // We may be modifying the source groups temporarily, so make a copy. std::vector sourceGroups = this->Makefile->GetSourceGroups(); @@ -1580,8 +1580,9 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo( std::string cmLocalVisualStudio7Generator::ComputeLongestObjectDirectory( cmGeneratorTarget const* target) const { - std::vector configs; - target->Target->GetMakefile()->GetConfigurations(configs); + std::vector configs = + target->Target->GetMakefile()->GetGeneratorConfigs( + cmMakefile::ExcludeEmptyConfig); // Compute the maximum length configuration name. std::string config_max; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 70861ce..e88f8ea 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1436,8 +1436,8 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent) if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) { cmProp p = parent->GetProperty("COMPILE_DEFINITIONS"); this->SetProperty("COMPILE_DEFINITIONS", p ? p->c_str() : nullptr); - std::vector configs; - this->GetConfigurations(configs); + std::vector configs = + this->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig); for (std::string const& config : configs) { std::string defPropName = cmStrCat("COMPILE_DEFINITIONS_", cmSystemTools::UpperCase(config)); @@ -3251,25 +3251,28 @@ void cmMakefile::RemoveVariablesInString(std::string& source, } } -std::string cmMakefile::GetConfigurations(std::vector& configs, - bool singleConfig) const +std::string cmMakefile::GetDefaultConfiguration() const { if (this->GetGlobalGenerator()->IsMultiConfig()) { - this->GetDefExpandList("CMAKE_CONFIGURATION_TYPES", configs); - return ""; - } - const std::string& buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE"); - if (singleConfig && !buildType.empty()) { - configs.push_back(buildType); + return std::string{}; } - return buildType; + return this->GetSafeDefinition("CMAKE_BUILD_TYPE"); } -std::vector cmMakefile::GetGeneratorConfigs() const +std::vector cmMakefile::GetGeneratorConfigs( + GeneratorConfigQuery mode) const { std::vector configs; - GetConfigurations(configs); - if (configs.empty()) { + if (this->GetGlobalGenerator()->IsMultiConfig() || + mode == cmMakefile::OnlyMultiConfig) { + this->GetDefExpandList("CMAKE_CONFIGURATION_TYPES", configs); + } else { + const std::string& buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE"); + if (!buildType.empty()) { + configs.emplace_back(buildType); + } + } + if (mode == cmMakefile::IncludeEmptyConfig && configs.empty()) { configs.emplace_back(); } return configs; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 323ab5a..be50413 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -343,12 +343,19 @@ public: */ void SetProjectName(std::string const& name); - /** Get the configurations to be generated. */ - std::string GetConfigurations(std::vector& configs, - bool single = true) const; + /* Get the default configuration */ + std::string GetDefaultConfiguration() const; + + enum GeneratorConfigQuery + { + IncludeEmptyConfig, // Include "" aka noconfig + ExcludeEmptyConfig, // Exclude "" aka noconfig + OnlyMultiConfig, + }; /** Get the configurations for dependency checking. */ - std::vector GetGeneratorConfigs() const; + std::vector GetGeneratorConfigs( + GeneratorConfigQuery mode) const; /** * Set the name of the library. diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 0c7591a..53a0cb7 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -65,7 +65,8 @@ cmNinjaTargetGenerator::cmNinjaTargetGenerator(cmGeneratorTarget* target) , LocalGenerator( static_cast(target->GetLocalGenerator())) { - for (auto const& fileConfig : target->Makefile->GetGeneratorConfigs()) { + for (auto const& fileConfig : + target->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig)) { this->Configs[fileConfig].MacOSXContentGenerator = cm::make_unique(this, fileConfig); } diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index e733a3e..7e0bf96 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -315,10 +315,9 @@ bool cmQtAutoGenInitializer::InitCustomTargets() { // Configurations this->MultiConfig = this->GlobalGen->IsMultiConfig(); - this->ConfigDefault = this->Makefile->GetConfigurations(this->ConfigsList); - if (this->ConfigsList.empty()) { - this->ConfigsList.push_back(this->ConfigDefault); - } + this->ConfigDefault = this->Makefile->GetDefaultConfiguration(); + this->ConfigsList = + this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); // Verbosity { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9f9b6f9..72c7600 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -419,8 +419,8 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, "INTERPROCEDURAL_OPTIMIZATION_" }; // Collect the set of configuration types. - std::vector configNames; - mf->GetConfigurations(configNames); + std::vector configNames = + mf->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig); for (std::string const& configName : configNames) { std::string configUpper = cmSystemTools::UpperCase(configName); for (auto const& prop : configProps) { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 31754f4..5f6b41d 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -232,7 +232,8 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator( , LocalGenerator( (cmLocalVisualStudio10Generator*)target->GetLocalGenerator()) { - this->Makefile->GetConfigurations(this->Configurations); + this->Configurations = + this->Makefile->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig); this->NsightTegra = gg->IsNsightTegra(); this->Android = gg->TargetsAndroid(); for (int i = 0; i < 4; ++i) { -- cgit v0.12