Refactor: Prepare Ninja generator for multi-config

This commit is contained in:
Kyle Edwards
2019-11-14 11:38:35 -05:00
parent 4047056a54
commit 3bc63e99e4
23 changed files with 641 additions and 527 deletions
+15 -7
View File
@@ -3,6 +3,7 @@
#include "cmLocalUnixMakefileGenerator3.h"
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <sstream>
#include <utility>
@@ -106,6 +107,13 @@ cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3(
cmLocalUnixMakefileGenerator3::~cmLocalUnixMakefileGenerator3() = default;
std::string cmLocalUnixMakefileGenerator3::GetConfigName() const
{
auto const& configNames = this->GetConfigNames();
assert(configNames.size() == 1);
return configNames.front();
}
void cmLocalUnixMakefileGenerator3::Generate()
{
// Record whether some options are enabled to avoid checking many
@@ -162,7 +170,7 @@ void cmLocalUnixMakefileGenerator3::GetLocalObjectFiles(
continue;
}
std::vector<cmSourceFile const*> objectSources;
gt->GetObjectSources(objectSources, this->ConfigName);
gt->GetObjectSources(objectSources, this->GetConfigName());
// Compute full path to object file directory for this target.
std::string dir = cmStrCat(gt->LocalGenerator->GetCurrentBinaryDirectory(),
'/', this->GetTargetDirectory(gt.get()), '/');
@@ -401,7 +409,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets(
// Add a local name for the rule to relink the target before
// installation.
if (target->NeedRelinkBeforeInstall(this->ConfigName)) {
if (target->NeedRelinkBeforeInstall(this->GetConfigName())) {
makeTargetName = cmStrCat(
this->GetRelativeTargetDirectory(target.get()), "/preinstall");
localName = cmStrCat(target->GetName(), "/preinstall");
@@ -858,7 +866,7 @@ void cmLocalUnixMakefileGenerator3::AppendCustomDepends(
std::vector<std::string>& depends, const std::vector<cmCustomCommand>& ccs)
{
for (cmCustomCommand const& cc : ccs) {
cmCustomCommandGenerator ccg(cc, this->ConfigName, this);
cmCustomCommandGenerator ccg(cc, this->GetConfigName(), this);
this->AppendCustomDepend(depends, ccg);
}
}
@@ -869,7 +877,7 @@ void cmLocalUnixMakefileGenerator3::AppendCustomDepend(
for (std::string const& d : ccg.GetDepends()) {
// Lookup the real name of the dependency in case it is a CMake target.
std::string dep;
if (this->GetRealDependency(d, this->ConfigName, dep)) {
if (this->GetRealDependency(d, this->GetConfigName(), dep)) {
depends.push_back(std::move(dep));
}
}
@@ -880,7 +888,7 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommands(
cmGeneratorTarget* target, std::string const& relative)
{
for (cmCustomCommand const& cc : ccs) {
cmCustomCommandGenerator ccg(cc, this->ConfigName, this);
cmCustomCommandGenerator ccg(cc, this->GetConfigName(), this);
this->AppendCustomCommand(commands, ccg, target, relative, true);
}
}
@@ -1839,7 +1847,7 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo(
// Build a list of preprocessor definitions for the target.
std::set<std::string> defines;
this->GetTargetDefines(target, this->ConfigName, implicitLang.first,
this->GetTargetDefines(target, this->GetConfigName(), implicitLang.first,
defines);
if (!defines.empty()) {
/* clang-format off */
@@ -1863,7 +1871,7 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo(
std::vector<std::string> includes;
this->GetIncludeDirectories(includes, target, implicitLang.first,
this->ConfigName);
this->GetConfigName());
std::string binaryDir = this->GetState()->GetBinaryDirectory();
if (this->Makefile->IsOn("CMAKE_DEPENDS_IN_PROJECT_ONLY")) {
std::string const& sourceDir = this->GetState()->GetSourceDirectory();