summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2020-06-30 17:44:37 (GMT)
committerBrad King <brad.king@kitware.com>2020-07-03 11:43:18 (GMT)
commit7a969fe21d736b6c6755b5dc7a105f1427242cdd (patch)
treee5049985a624ff703b52dcff17fad5f60cfbff8c
parent19f7588d3d715fdf3c32669fc756e2c68fbf1da5 (diff)
downloadCMake-7a969fe21d736b6c6755b5dc7a105f1427242cdd.zip
CMake-7a969fe21d736b6c6755b5dc7a105f1427242cdd.tar.gz
CMake-7a969fe21d736b6c6755b5dc7a105f1427242cdd.tar.bz2
cmMakefile: Refactor API to better handle empty config values
-rw-r--r--Source/cmComputeTargetDepends.cxx2
-rw-r--r--Source/cmExportCommand.cxx8
-rw-r--r--Source/cmExportFileGenerator.cxx5
-rw-r--r--Source/cmFileAPICodemodel.cxx2
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.cxx8
-rw-r--r--Source/cmGeneratorTarget.cxx13
-rw-r--r--Source/cmGlobalGenerator.cxx32
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx49
-rw-r--r--Source/cmGlobalVisualStudio71Generator.cxx4
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx5
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx7
-rw-r--r--Source/cmJsonObjects.cxx6
-rw-r--r--Source/cmLinkItemGraphVisitor.cxx3
-rw-r--r--Source/cmLocalCommonGenerator.cxx6
-rw-r--r--Source/cmLocalGenerator.cxx35
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx9
-rw-r--r--Source/cmMakefile.cxx31
-rw-r--r--Source/cmMakefile.h15
-rw-r--r--Source/cmNinjaTargetGenerator.cxx3
-rw-r--r--Source/cmQtAutoGenInitializer.cxx7
-rw-r--r--Source/cmTarget.cxx4
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx3
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<cmLinkItem> emitted;
std::vector<std::string> 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<std::string> const& args,
ebfg->SetExportOld(arguments.ExportOld);
// Compute the set of configurations exported.
- std::vector<std::string> configurationTypes;
- mf.GetConfigurations(configurationTypes);
- if (configurationTypes.empty()) {
- configurationTypes.emplace_back();
- }
+ std::vector<std::string> 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<std::string> configNames;
- gtarget->Target->GetMakefile()->GetConfigurations(configNames);
+ std::vector<std::string> 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<std::string> 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<std::string, std::string> outputFiles;
- std::vector<std::string> allConfigs;
- lg->GetMakefile()->GetConfigurations(allConfigs);
-
- if (allConfigs.empty()) {
- allConfigs.emplace_back();
- }
+ std::vector<std::string> allConfigs =
+ lg->GetMakefile()->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
std::vector<std::string> 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<std::string> configSet(configs.begin(), configs.end());
if (configSet == this->VisitedConfigsForObjects) {
return;
@@ -1778,8 +1779,8 @@ cmGeneratorTarget::GetAllConfigSources() const
void cmGeneratorTarget::ComputeAllConfigSources() const
{
- std::vector<std::string> configs;
- this->Makefile->GetConfigurations(configs);
+ std::vector<std::string> configs =
+ this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
std::map<cmSourceFile const*, size_t> index;
@@ -2812,7 +2813,7 @@ cmTargetTraceDependencies::cmTargetTraceDependencies(cmGeneratorTarget* target)
if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
std::set<cmSourceFile*> emitted;
std::vector<std::string> const& configs =
- this->Makefile->GetGeneratorConfigs();
+ this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
for (std::string const& c : configs) {
std::vector<cmSourceFile*> sources;
this->GeneratorTarget->GetSourceFiles(sources, c);
@@ -3023,7 +3024,7 @@ void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc)
// Queue the custom command dependencies.
std::set<std::string> emitted;
std::vector<std::string> 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<cmSourceFile*>& files) const
{
std::vector<std::string> 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<std::string> configs;
- target->Makefile->GetConfigurations(configs);
+ std::vector<std::string> configs =
+ target->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
std::vector<cmSourceFile*> 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<std::string> 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<std::string> configs;
- mf->GetConfigurations(configs);
+ std::vector<std::string> 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<cmSourceFile*> sources;
std::vector<std::string> 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<std::string> configs;
- std::string config = mf->GetConfigurations(configs, false);
+ std::vector<std::string> 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 <algorithm>
#include <cctype>
#include <cstdio>
-#include <iterator>
#include <sstream>
+#include <cm/iterator>
#include <cm/memory>
#include <cmext/algorithm>
#include <cmext/memory>
@@ -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<std::string> configs;
- dt.LG->GetMakefile()->GetConfigurations(configs, true);
- if (configs.empty()) {
- configs.emplace_back();
- }
+ std::vector<std::string> 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<std::string> configs;
- this->Makefiles[0]->GetConfigurations(configs, true);
- if (configs.empty()) {
- configs.emplace_back();
- }
+ std::vector<std::string> 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<std::string>& 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<cmLocalGenerator*>& generators)
{
- std::vector<std::string> configs;
- root->GetMakefile()->GetConfigurations(configs);
+ std::vector<std::string> 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<std::string> configs;
- target->Target->GetMakefile()->GetConfigurations(configs);
+ std::vector<std::string> 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<std::string> 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<std::string> configurationTypes;
- const std::string& config =
- this->Makefile->GetConfigurations(configurationTypes, false);
+ std::vector<std::string> 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<std::string> 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<std::string> configurationTypes;
- const std::string& config =
- this->Makefile->GetConfigurations(configurationTypes, false);
+ std::vector<std::string> 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<std::string> configNames;
- this->Makefile->GetConfigurations(configNames);
- if (configNames.empty()) {
- configNames.emplace_back();
- }
+ std::vector<std::string> 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<std::string> configNames;
- this->Makefile->GetConfigurations(configNames);
- if (configNames.empty()) {
- configNames.emplace_back();
- }
+ std::vector<std::string> configNames =
+ this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
using LanguagePair = std::pair<std::string, std::string>;
std::vector<LanguagePair> pairedLanguages{ { "OBJC", "C" },
@@ -2551,11 +2545,8 @@ void cmLocalGenerator::AppendFlagEscape(std::string& flags,
void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
{
- std::vector<std::string> configsList;
- std::string configDefault = this->Makefile->GetConfigurations(configsList);
- if (configsList.empty()) {
- configsList.push_back(configDefault);
- }
+ std::vector<std::string> 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<std::string> configs;
- this->Makefile->GetConfigurations(configs);
+ std::vector<std::string> configs =
+ this->Makefile->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig);
// We may be modifying the source groups temporarily, so make a copy.
std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
@@ -1580,8 +1580,9 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
std::string cmLocalVisualStudio7Generator::ComputeLongestObjectDirectory(
cmGeneratorTarget const* target) const
{
- std::vector<std::string> configs;
- target->Target->GetMakefile()->GetConfigurations(configs);
+ std::vector<std::string> 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<std::string> configs;
- this->GetConfigurations(configs);
+ std::vector<std::string> 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<std::string>& 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<std::string> cmMakefile::GetGeneratorConfigs() const
+std::vector<std::string> cmMakefile::GetGeneratorConfigs(
+ GeneratorConfigQuery mode) const
{
std::vector<std::string> 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<std::string>& 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<std::string> GetGeneratorConfigs() const;
+ std::vector<std::string> 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<cmLocalNinjaGenerator*>(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<MacOSXContentGeneratorType>(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<std::string> configNames;
- mf->GetConfigurations(configNames);
+ std::vector<std::string> 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) {