cmLocalGenerator: Store cmGeneratorTargets.

Relieve cmMakefile of this responsibility.
This commit is contained in:
Stephen Kelly 2015-09-16 05:21:07 +02:00 committed by Brad King
parent 488723f5cd
commit 2293d43d00
21 changed files with 60 additions and 60 deletions

View File

@ -43,7 +43,7 @@ std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const
{ {
std::string const& argv0 = this->CC.GetCommandLines()[c][0]; std::string const& argv0 = this->CC.GetCommandLines()[c][0];
cmGeneratorTarget* target = cmGeneratorTarget* target =
this->LG->GetMakefile()->FindGeneratorTargetToUse(argv0); this->LG->FindGeneratorTargetToUse(argv0);
if(target && target->GetType() == cmTarget::EXECUTABLE && if(target && target->GetType() == cmTarget::EXECUTABLE &&
(target->Target->IsImported() (target->Target->IsImported()
|| !this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING"))) || !this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING")))

View File

@ -42,7 +42,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
tei = targets.begin(); tei = targets.begin();
tei != targets.end(); ++tei) tei != targets.end(); ++tei)
{ {
cmGeneratorTarget *te = this->LG->GetMakefile() cmGeneratorTarget *te = this->LG
->FindGeneratorTargetToUse(*tei); ->FindGeneratorTargetToUse(*tei);
expectedTargets += sep + this->Namespace + te->Target->GetExportName(); expectedTargets += sep + this->Namespace + te->Target->GetExportName();
sep = " "; sep = " ";

View File

@ -965,8 +965,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
it != this->GlobalGenerator->GetLocalGenerators().end(); it != this->GlobalGenerator->GetLocalGenerators().end();
++it) ++it)
{ {
cmGeneratorTargetsType targets = (*it)->GetMakefile() cmGeneratorTargetsType targets = (*it)->GetGeneratorTargets();
->GetGeneratorTargets();
for (cmGeneratorTargetsType::iterator l = targets.begin(); for (cmGeneratorTargetsType::iterator l = targets.begin();
l != targets.end(); ++l) l != targets.end(); ++l)
{ {

View File

@ -1275,7 +1275,7 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
std::string tgtName = parameters.front(); std::string tgtName = parameters.front();
cmGeneratorTarget* gt = cmGeneratorTarget* gt =
context->LG->GetMakefile()->FindGeneratorTargetToUse(tgtName); context->LG->FindGeneratorTargetToUse(tgtName);
if (!gt) if (!gt)
{ {
std::ostringstream e; std::ostringstream e;
@ -1739,7 +1739,7 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode
return std::string(); return std::string();
} }
cmGeneratorTarget* target = cmGeneratorTarget* target =
context->LG->GetMakefile()->FindGeneratorTargetToUse(name); context->LG->FindGeneratorTargetToUse(name);
if(!target) if(!target)
{ {
::reportError(context, content->GetOriginalExpression(), ::reportError(context, content->GetOriginalExpression(),

View File

@ -2305,7 +2305,8 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep)
// Check for a target with this name. // Check for a target with this name.
if(cmGeneratorTarget* t if(cmGeneratorTarget* t
= this->Makefile->FindGeneratorTargetToUse(util)) = this->GeneratorTarget->
GetLocalGenerator()->FindGeneratorTargetToUse(util))
{ {
// If we find the target and the dep was given as a full path, // If we find the target and the dep was given as a full path,
// then make sure it was not a full path to something else, and // then make sure it was not a full path to something else, and

View File

@ -1578,7 +1578,7 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes,
this->GeneratorTargets[*j] = gt; this->GeneratorTargets[*j] = gt;
generatorTargets[*j] = gt; generatorTargets[*j] = gt;
} }
mf->SetGeneratorTargets(generatorTargets); lg->SetGeneratorTargets(generatorTargets);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -287,7 +287,7 @@ void cmGlobalGhsMultiGenerator::Generate()
{ {
cmLocalGhsMultiGenerator *lg = cmLocalGhsMultiGenerator *lg =
static_cast<cmLocalGhsMultiGenerator *>(this->LocalGenerators[i]); static_cast<cmLocalGhsMultiGenerator *>(this->LocalGenerators[i]);
cmGeneratorTargetsType tgts = lg->GetMakefile()->GetGeneratorTargets(); cmGeneratorTargetsType tgts = lg->GetGeneratorTargets();
this->UpdateBuildFiles(&tgts); this->UpdateBuildFiles(&tgts);
} }
} }

View File

@ -68,8 +68,7 @@ void cmGlobalKdevelopGenerator::Generate()
for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin(); for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
lg!=lgs.end(); lg++) lg!=lgs.end(); lg++)
{ {
cmMakefile* makefile=(*lg)->GetMakefile(); cmGeneratorTargetsType const& targets = (*lg)->GetGeneratorTargets();
cmGeneratorTargetsType const& targets = makefile->GetGeneratorTargets();
for (cmGeneratorTargetsType::const_iterator ti = targets.begin(); for (cmGeneratorTargetsType::const_iterator ti = targets.begin();
ti != targets.end(); ti++) ti != targets.end(); ti++)
{ {

View File

@ -461,7 +461,7 @@ cmGlobalUnixMakefileGenerator3
// The directory-level rule should depend on the target-level rules // The directory-level rule should depend on the target-level rules
// for all targets in the directory. // for all targets in the directory.
std::vector<std::string> depends; std::vector<std::string> depends;
cmGeneratorTargetsType targets = lg->GetMakefile()->GetGeneratorTargets(); cmGeneratorTargetsType targets = lg->GetGeneratorTargets();
for(cmGeneratorTargetsType::iterator l = targets.begin(); for(cmGeneratorTargetsType::iterator l = targets.begin();
l != targets.end(); ++l) l != targets.end(); ++l)
{ {
@ -627,7 +627,7 @@ cmGlobalUnixMakefileGenerator3
lg = static_cast<cmLocalUnixMakefileGenerator3 *> lg = static_cast<cmLocalUnixMakefileGenerator3 *>
(this->LocalGenerators[i]); (this->LocalGenerators[i]);
// for each target Generate the rule files for each target. // for each target Generate the rule files for each target.
cmGeneratorTargetsType targets = lg->GetMakefile()->GetGeneratorTargets(); cmGeneratorTargetsType targets = lg->GetGeneratorTargets();
for(cmGeneratorTargetsType::iterator t = targets.begin(); for(cmGeneratorTargetsType::iterator t = targets.begin();
t != targets.end(); ++t) t != targets.end(); ++t)
{ {
@ -728,7 +728,7 @@ cmGlobalUnixMakefileGenerator3
depends.push_back("cmake_check_build_system"); depends.push_back("cmake_check_build_system");
// for each target Generate the rule files for each target. // for each target Generate the rule files for each target.
cmGeneratorTargetsType targets = lg->GetMakefile()->GetGeneratorTargets(); cmGeneratorTargetsType targets = lg->GetGeneratorTargets();
for(cmGeneratorTargetsType::iterator t = targets.begin(); for(cmGeneratorTargetsType::iterator t = targets.begin();
t != targets.end(); ++t) t != targets.end(); ++t)
{ {

View File

@ -256,7 +256,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
noCommandLines); noCommandLines);
cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg); cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg);
mf->AddGeneratorTarget(tgt, gt); lg->AddGeneratorTarget(tgt, gt);
// Organize in the "predefined targets" folder: // Organize in the "predefined targets" folder:
// //

View File

@ -87,7 +87,7 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets()
"Build all projects"); "Build all projects");
cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]); cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]);
allBuild->GetMakefile()->AddGeneratorTarget(allBuild, gt); gen[0]->AddGeneratorTarget(allBuild, gt);
#if 0 #if 0
// Can't activate this code because we want ALL_BUILD // Can't activate this code because we want ALL_BUILD
@ -108,7 +108,7 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets()
i != gen.end(); ++i) i != gen.end(); ++i)
{ {
cmGeneratorTargetsType targets = cmGeneratorTargetsType targets =
(*i)->GetMakefile()->GetGeneratorTargets(); (*i)->GetGeneratorTargets();
for(cmGeneratorTargetsType::iterator t = targets.begin(); for(cmGeneratorTargetsType::iterator t = targets.begin();
t != targets.end(); ++t) t != targets.end(); ++t)
{ {

View File

@ -459,7 +459,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
"echo", "Build all projects"); "echo", "Build all projects");
cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root); cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root);
mf->AddGeneratorTarget(allbuild, allBuildGt); root->AddGeneratorTarget(allbuild, allBuildGt);
// Refer to the main build configuration file for easy editing. // Refer to the main build configuration file for easy editing.
std::string listfile = root->GetCurrentSourceDirectory(); std::string listfile = root->GetCurrentSourceDirectory();
@ -494,7 +494,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
"make", "-f", file.c_str()); "make", "-f", file.c_str());
cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root); cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root);
mf->AddGeneratorTarget(check, checkGt); root->AddGeneratorTarget(check, checkGt);
} }
// now make the allbuild depend on all the non-utility targets // now make the allbuild depend on all the non-utility targets

View File

@ -132,7 +132,7 @@ void cmLocalGenerator::TraceDependencies()
this->GlobalGenerator->CreateEvaluationSourceFiles(*ci); this->GlobalGenerator->CreateEvaluationSourceFiles(*ci);
} }
// Generate the rule files for each target. // Generate the rule files for each target.
cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); cmGeneratorTargetsType targets = this->GetGeneratorTargets();
for(cmGeneratorTargetsType::iterator t = targets.begin(); for(cmGeneratorTargetsType::iterator t = targets.begin();
t != targets.end(); ++t) t != targets.end(); ++t)
{ {
@ -448,6 +448,13 @@ void cmLocalGenerator::GenerateInstallRules()
} }
} }
void cmLocalGenerator::AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt)
{
this->GeneratorTargets[t] = gt;
this->GetGlobalGenerator()->AddGeneratorTarget(t, gt);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmLocalGenerator::ComputeTargetManifest() void cmLocalGenerator::ComputeTargetManifest()
{ {
@ -460,7 +467,7 @@ void cmLocalGenerator::ComputeTargetManifest()
} }
// Add our targets to the manifest for each configuration. // Add our targets to the manifest for each configuration.
cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); cmGeneratorTargetsType targets = this->GetGeneratorTargets();
for(cmGeneratorTargetsType::iterator t = targets.begin(); for(cmGeneratorTargetsType::iterator t = targets.begin();
t != targets.end(); ++t) t != targets.end(); ++t)
{ {
@ -1766,6 +1773,17 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
this->AddConfigVariableFlags(flags, flagsVar, config); this->AddConfigVariableFlags(flags, flagsVar, config);
} }
//----------------------------------------------------------------------------
cmGeneratorTarget*
cmLocalGenerator::FindGeneratorTargetToUse(const std::string& name) const
{
if (cmTarget *t = this->Makefile->FindTargetToUse(name))
{
return this->GetGlobalGenerator()->GetGeneratorTarget(t);
}
return 0;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmLocalGenerator::GetRealDependency(const std::string& inName, bool cmLocalGenerator::GetRealDependency(const std::string& inName,
const std::string& config, const std::string& config,
@ -1792,7 +1810,7 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName,
// Look for a CMake target with the given name. // Look for a CMake target with the given name.
if(cmGeneratorTarget* target = if(cmGeneratorTarget* target =
this->Makefile->FindGeneratorTargetToUse(name)) this->FindGeneratorTargetToUse(name))
{ {
// make sure it is not just a coincidence that the target name // make sure it is not just a coincidence that the target name
// found is part of the inName // found is part of the inName

View File

@ -112,6 +112,19 @@ public:
bool forResponseFile = false, bool forResponseFile = false,
const std::string& config = ""); const std::string& config = "");
const cmGeneratorTargetsType &GetGeneratorTargets() const
{
return this->GeneratorTargets;
}
void SetGeneratorTargets(const cmGeneratorTargetsType &targets)
{
this->GeneratorTargets = targets;
}
void AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt);
cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const;
/** /**
* Encode a list of preprocessor definitions for the compiler * Encode a list of preprocessor definitions for the compiler
* command line. * command line.
@ -354,6 +367,7 @@ protected:
std::set<std::string> ObjectMaxPathViolations; std::set<std::string> ObjectMaxPathViolations;
std::set<cmTarget const*> WarnCMP0063; std::set<cmTarget const*> WarnCMP0063;
cmGeneratorTargetsType GeneratorTargets;
bool EmitUniversalBinaryFlags; bool EmitUniversalBinaryFlags;

View File

@ -26,7 +26,7 @@ cmLocalGhsMultiGenerator::~cmLocalGhsMultiGenerator() {}
void cmLocalGhsMultiGenerator::Generate() void cmLocalGhsMultiGenerator::Generate()
{ {
cmGeneratorTargetsType tgts = this->GetMakefile()->GetGeneratorTargets(); cmGeneratorTargetsType tgts = this->GetGeneratorTargets();
for (cmGeneratorTargetsType::iterator l = tgts.begin(); l != tgts.end(); for (cmGeneratorTargetsType::iterator l = tgts.begin(); l != tgts.end();
++l) ++l)

View File

@ -73,7 +73,7 @@ void cmLocalNinjaGenerator::Generate()
} }
} }
cmGeneratorTargetsType targets = this->GetMakefile()->GetGeneratorTargets(); cmGeneratorTargetsType targets = this->GetGeneratorTargets();
for(cmGeneratorTargetsType::iterator t = targets.begin(); for(cmGeneratorTargetsType::iterator t = targets.begin();
t != targets.end(); ++t) t != targets.end(); ++t)
{ {

View File

@ -113,7 +113,7 @@ void cmLocalUnixMakefileGenerator3::Generate()
this->Makefile->IsOn("CMAKE_SKIP_ASSEMBLY_SOURCE_RULES"); this->Makefile->IsOn("CMAKE_SKIP_ASSEMBLY_SOURCE_RULES");
// Generate the rule files for each target. // Generate the rule files for each target.
cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); cmGeneratorTargetsType targets = this->GetGeneratorTargets();
cmGlobalUnixMakefileGenerator3* gg = cmGlobalUnixMakefileGenerator3* gg =
static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator); static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
for(cmGeneratorTargetsType::iterator t = targets.begin(); for(cmGeneratorTargetsType::iterator t = targets.begin();
@ -175,7 +175,7 @@ void cmLocalUnixMakefileGenerator3::
GetLocalObjectFiles(std::map<std::string, LocalObjectInfo> &localObjectFiles) GetLocalObjectFiles(std::map<std::string, LocalObjectInfo> &localObjectFiles)
{ {
std::set<std::string> emitted; std::set<std::string> emitted;
cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); cmGeneratorTargetsType targets = this->GetGeneratorTargets();
for(cmGeneratorTargetsType::iterator ti = targets.begin(); for(cmGeneratorTargetsType::iterator ti = targets.begin();
ti != targets.end(); ++ti) ti != targets.end(); ++ti)
{ {
@ -418,7 +418,7 @@ void cmLocalUnixMakefileGenerator3
// for each target we just provide a rule to cd up to the top and do a make // for each target we just provide a rule to cd up to the top and do a make
// on the target // on the target
cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); cmGeneratorTargetsType targets = this->GetGeneratorTargets();
std::string localName; std::string localName;
for(cmGeneratorTargetsType::iterator t = targets.begin(); for(cmGeneratorTargetsType::iterator t = targets.begin();
t != targets.end(); ++t) t != targets.end(); ++t)

View File

@ -1812,12 +1812,6 @@ const char* cmMakefile::GetCurrentBinaryDirectory() const
return this->StateSnapshot.GetDirectory().GetCurrentBinary(); return this->StateSnapshot.GetDirectory().GetCurrentBinary();
} }
void cmMakefile::AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt)
{
this->GeneratorTargets[t] = gt;
this->GetGlobalGenerator()->AddGeneratorTarget(t, gt);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmMakefile::AddIncludeDirectories(const std::vector<std::string> &incs, void cmMakefile::AddIncludeDirectories(const std::vector<std::string> &incs,
bool before) bool before)
@ -4320,17 +4314,6 @@ bool cmMakefile::IsAlias(const std::string& name) const
return this->GetGlobalGenerator()->IsAlias(name); return this->GetGlobalGenerator()->IsAlias(name);
} }
//----------------------------------------------------------------------------
cmGeneratorTarget*
cmMakefile::FindGeneratorTargetToUse(const std::string& name) const
{
if (cmTarget *t = this->FindTargetToUse(name))
{
return this->GetGlobalGenerator()->GetGeneratorTarget(t);
}
return 0;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
bool isCustom) const bool isCustom) const

View File

@ -17,7 +17,6 @@
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmTarget.h" #include "cmTarget.h"
#include "cmNewLineStyle.h" #include "cmNewLineStyle.h"
#include "cmGeneratorTarget.h"
#include "cmExpandedCommandArgument.h" #include "cmExpandedCommandArgument.h"
#include "cmake.h" #include "cmake.h"
#include "cmState.h" #include "cmState.h"
@ -393,17 +392,6 @@ public:
return this->ImportedTargetsOwned; return this->ImportedTargetsOwned;
} }
const cmGeneratorTargetsType &GetGeneratorTargets() const
{
return this->GeneratorTargets;
}
void SetGeneratorTargets(const cmGeneratorTargetsType &targets)
{
this->GeneratorTargets = targets;
}
void AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt);
cmTarget* FindTarget(const std::string& name, cmTarget* FindTarget(const std::string& name,
bool excludeAliases = false) const; bool excludeAliases = false) const;
@ -412,7 +400,6 @@ public:
cmTarget* FindTargetToUse(const std::string& name, cmTarget* FindTargetToUse(const std::string& name,
bool excludeAliases = false) const; bool excludeAliases = false) const;
bool IsAlias(const std::string& name) const; bool IsAlias(const std::string& name) const;
cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const;
/** /**
* Mark include directories as system directories. * Mark include directories as system directories.
@ -816,7 +803,6 @@ protected:
typedef std::map<std::string, cmTarget*> TargetMap; typedef std::map<std::string, cmTarget*> TargetMap;
#endif #endif
TargetMap AliasTargets; TargetMap AliasTargets;
cmGeneratorTargetsType GeneratorTargets;
std::vector<cmSourceFile*> SourceFiles; std::vector<cmSourceFile*> SourceFiles;
// Tests // Tests

View File

@ -886,7 +886,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
commandLines, false, autogenComment.c_str()); commandLines, false, autogenComment.c_str());
cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg);
makefile->AddGeneratorTarget(autogenTarget, gt); lg->AddGeneratorTarget(autogenTarget, gt);
// Set target folder // Set target folder
const char* autogenFolder = makefile->GetState() const char* autogenFolder = makefile->GetState()

View File

@ -89,7 +89,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
// be translated. // be translated.
std::string exe = command[0]; std::string exe = command[0];
cmGeneratorTarget* target = cmGeneratorTarget* target =
this->LG->GetMakefile()->FindGeneratorTargetToUse(exe); this->LG->FindGeneratorTargetToUse(exe);
if(target && target->GetType() == cmTarget::EXECUTABLE) if(target && target->GetType() == cmTarget::EXECUTABLE)
{ {
// Use the target file on disk. // Use the target file on disk.