cmMakefile: Add configurations getter with empty configuration default

This commit is contained in:
Daniel Eiband 2019-08-30 11:47:37 +02:00
parent 3ec986ce8e
commit 10507c6dc0
7 changed files with 34 additions and 49 deletions

View File

@ -197,11 +197,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
{ {
std::set<cmLinkItem> emitted; std::set<cmLinkItem> emitted;
std::vector<std::string> configs; std::vector<std::string> const& configs =
depender->Makefile->GetConfigurations(configs); depender->Makefile->GetGeneratorConfigs();
if (configs.empty()) {
configs.emplace_back();
}
for (std::string const& it : configs) { for (std::string const& it : configs) {
std::vector<cmSourceFile const*> objectFiles; std::vector<cmSourceFile const*> objectFiles;
depender->GetExternalObjects(objectFiles, it); depender->GetExternalObjects(objectFiles, it);

View File

@ -423,20 +423,17 @@ Json::Value Codemodel::DumpPaths()
Json::Value Codemodel::DumpConfigurations() Json::Value Codemodel::DumpConfigurations()
{ {
std::vector<std::string> configs; Json::Value configurations = Json::arrayValue;
cmGlobalGenerator* gg = cmGlobalGenerator* gg =
this->FileAPI.GetCMakeInstance()->GetGlobalGenerator(); this->FileAPI.GetCMakeInstance()->GetGlobalGenerator();
auto makefiles = gg->GetMakefiles(); auto makefiles = gg->GetMakefiles();
if (!makefiles.empty()) { if (!makefiles.empty()) {
makefiles[0]->GetConfigurations(configs); std::vector<std::string> const& configs =
if (configs.empty()) { makefiles[0]->GetGeneratorConfigs();
configs.emplace_back(); 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; return configurations;
} }

View File

@ -786,11 +786,8 @@ void cmGeneratorTarget::ComputeObjectMapping()
return; return;
} }
std::vector<std::string> configs; std::vector<std::string> const& configs =
this->Makefile->GetConfigurations(configs); this->Makefile->GetGeneratorConfigs();
if (configs.empty()) {
configs.emplace_back();
}
for (std::string const& c : configs) { for (std::string const& c : configs) {
std::vector<cmSourceFile const*> sourceFiles; std::vector<cmSourceFile const*> sourceFiles;
this->GetObjectSources(sourceFiles, c); this->GetObjectSources(sourceFiles, c);
@ -2634,12 +2631,9 @@ cmTargetTraceDependencies::cmTargetTraceDependencies(cmGeneratorTarget* target)
// Queue all the source files already specified for the target. // Queue all the source files already specified for the target.
if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
std::vector<std::string> configs;
this->Makefile->GetConfigurations(configs);
if (configs.empty()) {
configs.emplace_back();
}
std::set<cmSourceFile*> emitted; std::set<cmSourceFile*> emitted;
std::vector<std::string> const& configs =
this->Makefile->GetGeneratorConfigs();
for (std::string const& c : configs) { for (std::string const& c : configs) {
std::vector<cmSourceFile*> sources; std::vector<cmSourceFile*> sources;
this->GeneratorTarget->GetSourceFiles(sources, c); this->GeneratorTarget->GetSourceFiles(sources, c);
@ -2825,12 +2819,9 @@ void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc)
} }
// Queue the custom command dependencies. // Queue the custom command dependencies.
std::vector<std::string> configs;
std::set<std::string> emitted; std::set<std::string> emitted;
this->Makefile->GetConfigurations(configs); std::vector<std::string> const& configs =
if (configs.empty()) { this->Makefile->GetGeneratorConfigs();
configs.emplace_back();
}
for (std::string const& conf : configs) { for (std::string const& conf : configs) {
this->FollowCommandDepends(cc, conf, emitted); this->FollowCommandDepends(cc, conf, emitted);
} }
@ -6077,11 +6068,8 @@ const cmLinkImplementation* cmGeneratorTarget::GetLinkImplementation(
bool cmGeneratorTarget::GetConfigCommonSourceFiles( bool cmGeneratorTarget::GetConfigCommonSourceFiles(
std::vector<cmSourceFile*>& files) const std::vector<cmSourceFile*>& files) const
{ {
std::vector<std::string> configs; std::vector<std::string> const& configs =
this->Makefile->GetConfigurations(configs); this->Makefile->GetGeneratorConfigs();
if (configs.empty()) {
configs.emplace_back();
}
std::vector<std::string>::const_iterator it = configs.begin(); std::vector<std::string>::const_iterator it = configs.begin();
const std::string& firstConfig = *it; const std::string& firstConfig = *it;

View File

@ -337,12 +337,8 @@ bool cmGlobalGenerator::CheckTargetsForType() const
for (cmGeneratorTarget* target : generator->GetGeneratorTargets()) { for (cmGeneratorTarget* target : generator->GetGeneratorTargets()) {
if (target->GetType() == cmStateEnums::EXECUTABLE && if (target->GetType() == cmStateEnums::EXECUTABLE &&
target->GetPropertyAsBool("WIN32_EXECUTABLE")) { target->GetPropertyAsBool("WIN32_EXECUTABLE")) {
std::vector<std::string> configs; std::vector<std::string> const& configs =
target->Makefile->GetConfigurations(configs); target->Makefile->GetGeneratorConfigs();
if (configs.empty()) {
configs.emplace_back();
}
for (std::string const& config : configs) { for (std::string const& config : configs) {
if (target->GetLinkerLanguage(config) == "Swift") { if (target->GetLinkerLanguage(config) == "Swift") {
this->GetCMakeInstance()->IssueMessage( this->GetCMakeInstance()->IssueMessage(
@ -2963,11 +2959,8 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
// List the source files with any per-source labels. // List the source files with any per-source labels.
fout << "# Source files and their labels\n"; fout << "# Source files and their labels\n";
std::vector<cmSourceFile*> sources; std::vector<cmSourceFile*> sources;
std::vector<std::string> configs; std::vector<std::string> const& configs =
target->Target->GetMakefile()->GetConfigurations(configs); target->Target->GetMakefile()->GetGeneratorConfigs();
if (configs.empty()) {
configs.emplace_back();
}
for (std::string const& c : configs) { for (std::string const& c : configs) {
target->GetSourceFiles(sources, c); target->GetSourceFiles(sources, c);
} }

View File

@ -257,11 +257,8 @@ static void MoveSystemIncludesToEnd(std::vector<BT<std::string>>& includeDirs,
void cmLocalGenerator::TraceDependencies() void cmLocalGenerator::TraceDependencies()
{ {
std::vector<std::string> configs; std::vector<std::string> const& configs =
this->Makefile->GetConfigurations(configs); this->Makefile->GetGeneratorConfigs();
if (configs.empty()) {
configs.emplace_back();
}
for (std::string const& c : configs) { for (std::string const& c : configs) {
this->GlobalGenerator->CreateEvaluationSourceFiles(c); this->GlobalGenerator->CreateEvaluationSourceFiles(c);
} }

View File

@ -3057,6 +3057,16 @@ std::string cmMakefile::GetConfigurations(std::vector<std::string>& configs,
return buildType; return buildType;
} }
std::vector<std::string> cmMakefile::GetGeneratorConfigs() const
{
std::vector<std::string> configs;
GetConfigurations(configs);
if (configs.empty()) {
configs.emplace_back();
}
return configs;
}
bool cmMakefile::IsFunctionBlocked(const cmListFileFunction& lff, bool cmMakefile::IsFunctionBlocked(const cmListFileFunction& lff,
cmExecutionStatus& status) cmExecutionStatus& status)
{ {

View File

@ -292,6 +292,9 @@ public:
std::string GetConfigurations(std::vector<std::string>& configs, std::string GetConfigurations(std::vector<std::string>& configs,
bool single = true) const; bool single = true) const;
/** Get the configurations for dependency checking. */
std::vector<std::string> GetGeneratorConfigs() const;
/** /**
* Set the name of the library. * Set the name of the library.
*/ */