cmLocalGenerator: Initialize state before creating cmMakefile.

Access the state from the local generator in the cmMakefile.
This commit is contained in:
Stephen Kelly 2015-05-03 16:51:51 +02:00
parent 34c9ee2ed7
commit 76b598319f
3 changed files with 23 additions and 15 deletions

View File

@ -51,6 +51,13 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg,
if (parent) if (parent)
{ {
parent->AddChild(this); parent->AddChild(this);
this->StateSnapshot =
this->GetState()->CreateSnapshot(parent->StateSnapshot);
}
else
{
this->StateSnapshot =
this->GetState()->CreateSnapshot(cmState::Snapshot(this->GetState()));
} }
this->Makefile = new cmMakefile(this); this->Makefile = new cmMakefile(this);
@ -573,6 +580,16 @@ void cmLocalGenerator::GenerateTargetManifest()
} }
} }
cmState* cmLocalGenerator::GetState() const
{
return this->GlobalGenerator->GetCMakeInstance()->GetState();
}
cmState::Snapshot cmLocalGenerator::GetStateSnapshot() const
{
return this->StateSnapshot;
}
void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
const std::string& lang, const std::string& lang,
cmSourceFile& source, cmSourceFile& source,

View File

@ -13,6 +13,7 @@
#define cmLocalGenerator_h #define cmLocalGenerator_h
#include "cmStandardIncludes.h" #include "cmStandardIncludes.h"
#include "cmState.h"
class cmMakefile; class cmMakefile;
class cmGlobalGenerator; class cmGlobalGenerator;
@ -88,6 +89,9 @@ public:
const cmGlobalGenerator *GetGlobalGenerator() const { const cmGlobalGenerator *GetGlobalGenerator() const {
return this->GlobalGenerator; } return this->GlobalGenerator; }
cmState* GetState() const;
cmState::Snapshot GetStateSnapshot() const;
/** /**
* Convert something to something else. This is a centralized conversion * Convert something to something else. This is a centralized conversion
* routine used by the generators to handle relative paths and the like. * routine used by the generators to handle relative paths and the like.
@ -442,6 +446,7 @@ protected:
void ReadInputFile(); void ReadInputFile();
cmMakefile *Makefile; cmMakefile *Makefile;
cmState::Snapshot StateSnapshot;
cmGlobalGenerator *GlobalGenerator; cmGlobalGenerator *GlobalGenerator;
std::vector<std::string> HomeDirectoryComponents; std::vector<std::string> HomeDirectoryComponents;
std::vector<std::string> StartDirectoryComponents; std::vector<std::string> StartDirectoryComponents;

View File

@ -153,27 +153,13 @@ public:
cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) cmMakefile::cmMakefile(cmLocalGenerator* localGenerator)
: Internal(new Internals), : Internal(new Internals),
LocalGenerator(localGenerator), LocalGenerator(localGenerator),
StateSnapshot(localGenerator->GetGlobalGenerator() StateSnapshot(localGenerator->GetStateSnapshot())
->GetCMakeInstance()->GetState())
{ {
this->Internal->PushDefinitions(); this->Internal->PushDefinitions();
this->Internal->VarInitStack.push(std::set<std::string>()); this->Internal->VarInitStack.push(std::set<std::string>());
this->Internal->VarUsageStack.push(std::set<std::string>()); this->Internal->VarUsageStack.push(std::set<std::string>());
this->Internal->IsSourceFileTryCompile = false; this->Internal->IsSourceFileTryCompile = false;
if (this->LocalGenerator->GetParent())
{
cmMakefile* parentMf = this->LocalGenerator->GetParent()->GetMakefile();
this->StateSnapshot =
this->GetState()->CreateSnapshot(parentMf->StateSnapshot);
}
else
{
this->StateSnapshot =
this->GetState()->CreateSnapshot(this->StateSnapshot);
}
// Initialize these first since AddDefaultDefinitions calls AddDefinition // Initialize these first since AddDefaultDefinitions calls AddDefinition
this->WarnUnused = false; this->WarnUnused = false;
this->CheckSystemVars = false; this->CheckSystemVars = false;