cmGeneratorTarget: Access global state through LocalGenerator.

This commit is contained in:
Stephen Kelly 2015-10-16 19:19:49 +02:00
parent 50fb2ad646
commit fb4fca0b5e
3 changed files with 12 additions and 15 deletions

View File

@ -400,8 +400,7 @@ cmCommonTargetGenerator::GetLinkedTargetDirectories() const
&& emitted.insert(linkee).second) && emitted.insert(linkee).second)
{ {
cmLocalGenerator* lg = linkee->GetLocalGenerator(); cmLocalGenerator* lg = linkee->GetLocalGenerator();
cmMakefile* mf = linkee->Target->GetMakefile(); std::string di = lg->GetCurrentBinaryDirectory();
std::string di = mf->GetCurrentBinaryDirectory();
di += "/"; di += "/";
di += lg->GetTargetDirectory(linkee); di += lg->GetTargetDirectory(linkee);
dirs.push_back(di); dirs.push_back(di);

View File

@ -1497,11 +1497,11 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode
const char *policy = targetPolicyWhitelist[i]; const char *policy = targetPolicyWhitelist[i];
if (parameters.front() == policy) if (parameters.front() == policy)
{ {
cmMakefile *mf = context->HeadTarget->Target->GetMakefile(); cmLocalGenerator* lg = context->HeadTarget->GetLocalGenerator();
switch(statusForTarget(context->HeadTarget, policy)) switch(statusForTarget(context->HeadTarget, policy))
{ {
case cmPolicies::WARN: case cmPolicies::WARN:
mf->IssueMessage(cmake::AUTHOR_WARNING, lg->IssueMessage(cmake::AUTHOR_WARNING,
cmPolicies::GetPolicyWarning(policyForString(policy))); cmPolicies::GetPolicyWarning(policyForString(policy)));
case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_ALWAYS:

View File

@ -985,7 +985,7 @@ static bool processSources(cmGeneratorTarget const* tgt,
{ {
if(!e.empty()) if(!e.empty())
{ {
cmake* cm = mf->GetCMakeInstance(); cmake* cm = tgt->GetLocalGenerator()->GetCMakeInstance();
cm->IssueMessage(cmake::FATAL_ERROR, e, cm->IssueMessage(cmake::FATAL_ERROR, e,
tgt->Target->GetBacktrace()); tgt->Target->GetBacktrace());
} }
@ -1043,7 +1043,7 @@ void cmGeneratorTarget::GetSourceFiles(std::vector<std::string> &files,
{ {
assert(this->GetType() != cmState::INTERFACE_LIBRARY); assert(this->GetType() != cmState::INTERFACE_LIBRARY);
if (!this->Makefile->GetGlobalGenerator()->GetConfigureDoneCMP0026()) if (!this->LocalGenerator->GetGlobalGenerator()->GetConfigureDoneCMP0026())
{ {
// At configure-time, this method can be called as part of getting the // At configure-time, this method can be called as part of getting the
// LOCATION property or to export() a file to be include()d. However // LOCATION property or to export() a file to be include()d. However
@ -1088,7 +1088,7 @@ void cmGeneratorTarget::GetSourceFiles(std::vector<std::string> &files,
"SOURCES") "SOURCES")
!= debugProperties.end(); != debugProperties.end();
if (this->Makefile->GetGlobalGenerator()->GetConfigureDoneCMP0026()) if (this->LocalGenerator->GetGlobalGenerator()->GetConfigureDoneCMP0026())
{ {
this->DebugSourcesDone = true; this->DebugSourcesDone = true;
} }
@ -1447,7 +1447,7 @@ bool cmGeneratorTarget::HasMacOSXRpathInstallNameDir(
w << " This could be because you are using a Mac OS X version"; w << " This could be because you are using a Mac OS X version";
w << " less than 10.5 or because CMake's platform configuration is"; w << " less than 10.5 or because CMake's platform configuration is";
w << " corrupt."; w << " corrupt.";
cmake* cm = this->Makefile->GetCMakeInstance(); cmake* cm = this->LocalGenerator->GetCMakeInstance();
cm->IssueMessage(cmake::FATAL_ERROR, w.str(), cm->IssueMessage(cmake::FATAL_ERROR, w.str(),
this->Target->GetBacktrace()); this->Target->GetBacktrace());
} }
@ -1474,7 +1474,7 @@ bool cmGeneratorTarget::MacOSXRpathInstallNameDirDefault() const
if(cmp0042 == cmPolicies::WARN) if(cmp0042 == cmPolicies::WARN)
{ {
this->Makefile->GetGlobalGenerator()-> this->LocalGenerator->GetGlobalGenerator()->
AddCMP0042WarnTarget(this->GetName()); AddCMP0042WarnTarget(this->GetName());
} }
@ -1782,14 +1782,12 @@ class cmTargetSelectLinker
{ {
int Preference; int Preference;
cmGeneratorTarget const* Target; cmGeneratorTarget const* Target;
cmMakefile* Makefile;
cmGlobalGenerator* GG; cmGlobalGenerator* GG;
std::set<std::string> Preferred; std::set<std::string> Preferred;
public: public:
cmTargetSelectLinker(cmGeneratorTarget const* target) cmTargetSelectLinker(cmGeneratorTarget const* target)
: Preference(0), Target(target) : Preference(0), Target(target)
{ {
this->Makefile = this->Target->Makefile;
this->GG = this->Target->GetLocalGenerator()->GetGlobalGenerator(); this->GG = this->Target->GetLocalGenerator()->GetGlobalGenerator();
} }
void Consider(const char* lang) void Consider(const char* lang)
@ -1823,7 +1821,7 @@ public:
e << " " << *li << "\n"; e << " " << *li << "\n";
} }
e << "Set the LINKER_LANGUAGE property for this target."; e << "Set the LINKER_LANGUAGE property for this target.";
cmake* cm = this->Makefile->GetCMakeInstance(); cmake* cm = this->Target->GetLocalGenerator()->GetCMakeInstance();
cm->IssueMessage(cmake::FATAL_ERROR, e.str(), cm->IssueMessage(cmake::FATAL_ERROR, e.str(),
this->Target->Target->GetBacktrace()); this->Target->Target->GetBacktrace());
} }
@ -4823,7 +4821,7 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config,
// specified as a relative path. Treat a relative path as // specified as a relative path. Treat a relative path as
// relative to the current output directory for this makefile. // relative to the current output directory for this makefile.
out = (cmSystemTools::CollapseFullPath out = (cmSystemTools::CollapseFullPath
(out, this->Makefile->GetCurrentBinaryDirectory())); (out, this->LocalGenerator->GetCurrentBinaryDirectory()));
// The generator may add the configuration's subdirectory. // The generator may add the configuration's subdirectory.
if(!conf.empty()) if(!conf.empty())
@ -4888,7 +4886,7 @@ bool cmGeneratorTarget::ComputePDBOutputDir(const std::string& kind,
// specified as a relative path. Treat a relative path as // specified as a relative path. Treat a relative path as
// relative to the current output directory for this makefile. // relative to the current output directory for this makefile.
out = (cmSystemTools::CollapseFullPath out = (cmSystemTools::CollapseFullPath
(out, this->Makefile->GetCurrentBinaryDirectory())); (out, this->LocalGenerator->GetCurrentBinaryDirectory()));
// The generator may add the configuration's subdirectory. // The generator may add the configuration's subdirectory.
if(!conf.empty()) if(!conf.empty())
@ -5555,7 +5553,7 @@ bool cmGeneratorTarget::HasImportLibrary() const
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string cmGeneratorTarget::GetSupportDirectory() const std::string cmGeneratorTarget::GetSupportDirectory() const
{ {
std::string dir = this->Makefile->GetCurrentBinaryDirectory(); std::string dir = this->LocalGenerator->GetCurrentBinaryDirectory();
dir += cmake::GetCMakeFilesDirectory(); dir += cmake::GetCMakeFilesDirectory();
dir += "/"; dir += "/";
dir += this->GetName(); dir += this->GetName();