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::vector<std::string> configs;
depender->Makefile->GetConfigurations(configs);
if (configs.empty()) {
configs.emplace_back();
}
std::vector<std::string> const& configs =
depender->Makefile->GetGeneratorConfigs();
for (std::string const& it : configs) {
std::vector<cmSourceFile const*> objectFiles;
depender->GetExternalObjects(objectFiles, it);

View File

@ -423,20 +423,17 @@ Json::Value Codemodel::DumpPaths()
Json::Value Codemodel::DumpConfigurations()
{
std::vector<std::string> 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<std::string> 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;
}

View File

@ -786,11 +786,8 @@ void cmGeneratorTarget::ComputeObjectMapping()
return;
}
std::vector<std::string> configs;
this->Makefile->GetConfigurations(configs);
if (configs.empty()) {
configs.emplace_back();
}
std::vector<std::string> const& configs =
this->Makefile->GetGeneratorConfigs();
for (std::string const& c : configs) {
std::vector<cmSourceFile const*> 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<std::string> configs;
this->Makefile->GetConfigurations(configs);
if (configs.empty()) {
configs.emplace_back();
}
std::set<cmSourceFile*> emitted;
std::vector<std::string> const& configs =
this->Makefile->GetGeneratorConfigs();
for (std::string const& c : configs) {
std::vector<cmSourceFile*> sources;
this->GeneratorTarget->GetSourceFiles(sources, c);
@ -2825,12 +2819,9 @@ void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc)
}
// Queue the custom command dependencies.
std::vector<std::string> configs;
std::set<std::string> emitted;
this->Makefile->GetConfigurations(configs);
if (configs.empty()) {
configs.emplace_back();
}
std::vector<std::string> 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<cmSourceFile*>& files) const
{
std::vector<std::string> configs;
this->Makefile->GetConfigurations(configs);
if (configs.empty()) {
configs.emplace_back();
}
std::vector<std::string> const& configs =
this->Makefile->GetGeneratorConfigs();
std::vector<std::string>::const_iterator it = configs.begin();
const std::string& firstConfig = *it;

View File

@ -337,12 +337,8 @@ bool cmGlobalGenerator::CheckTargetsForType() const
for (cmGeneratorTarget* target : generator->GetGeneratorTargets()) {
if (target->GetType() == cmStateEnums::EXECUTABLE &&
target->GetPropertyAsBool("WIN32_EXECUTABLE")) {
std::vector<std::string> configs;
target->Makefile->GetConfigurations(configs);
if (configs.empty()) {
configs.emplace_back();
}
std::vector<std::string> 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<cmSourceFile*> sources;
std::vector<std::string> configs;
target->Target->GetMakefile()->GetConfigurations(configs);
if (configs.empty()) {
configs.emplace_back();
}
std::vector<std::string> const& configs =
target->Target->GetMakefile()->GetGeneratorConfigs();
for (std::string const& c : configs) {
target->GetSourceFiles(sources, c);
}

View File

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

View File

@ -3057,6 +3057,16 @@ std::string cmMakefile::GetConfigurations(std::vector<std::string>& configs,
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,
cmExecutionStatus& status)
{

View File

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