cmGlobalGenerator: Remove direct storage of targets
Find the target by looping when needed.
This commit is contained in:
parent
383bfd9543
commit
0c97d32f7a
|
@ -1637,8 +1637,6 @@ void cmGlobalGenerator::ClearGeneratorMembers()
|
||||||
|
|
||||||
this->ExportSets.clear();
|
this->ExportSets.clear();
|
||||||
this->TargetDependencies.clear();
|
this->TargetDependencies.clear();
|
||||||
this->TotalTargets.clear();
|
|
||||||
this->ImportedTargets.clear();
|
|
||||||
this->ProjectMap.clear();
|
this->ProjectMap.clear();
|
||||||
this->RuleHashes.clear();
|
this->RuleHashes.clear();
|
||||||
this->DirectoryContentMap.clear();
|
this->DirectoryContentMap.clear();
|
||||||
|
@ -2180,6 +2178,41 @@ bool cmGlobalGenerator::IsAlias(const std::string& name) const
|
||||||
return this->AliasTargets.find(name) != this->AliasTargets.end();
|
return this->AliasTargets.find(name) != this->AliasTargets.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmTarget* cmGlobalGenerator::FindTargetImpl(std::string const& name) const
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < this->Makefiles.size(); ++i)
|
||||||
|
{
|
||||||
|
cmTargets& tgts = this->Makefiles[i]->GetTargets();
|
||||||
|
for (cmTargets::iterator it = tgts.begin(); it != tgts.end(); ++it)
|
||||||
|
{
|
||||||
|
if (it->second.GetName() == name)
|
||||||
|
{
|
||||||
|
return &it->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmTarget*
|
||||||
|
cmGlobalGenerator::FindImportedTargetImpl(std::string const& name) const
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < this->Makefiles.size(); ++i)
|
||||||
|
{
|
||||||
|
std::vector<cmTarget*> tgts =
|
||||||
|
this->Makefiles[i]->GetOwnedImportedTargets();
|
||||||
|
for (std::vector<cmTarget*>::iterator it = tgts.begin();
|
||||||
|
it != tgts.end(); ++it)
|
||||||
|
{
|
||||||
|
if ((*it)->GetName() == name && (*it)->IsImportedGloballyVisible())
|
||||||
|
{
|
||||||
|
return *it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmTarget*
|
cmTarget*
|
||||||
cmGlobalGenerator::FindTarget(const std::string& name,
|
cmGlobalGenerator::FindTarget(const std::string& name,
|
||||||
|
@ -2193,17 +2226,11 @@ cmGlobalGenerator::FindTarget(const std::string& name,
|
||||||
return ai->second;
|
return ai->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TargetMap::const_iterator i = this->TotalTargets.find ( name );
|
if (cmTarget* tgt = this->FindTargetImpl(name))
|
||||||
if ( i != this->TotalTargets.end() )
|
|
||||||
{
|
{
|
||||||
return i->second;
|
return tgt;
|
||||||
}
|
}
|
||||||
i = this->ImportedTargets.find(name);
|
return this->FindImportedTargetImpl(name);
|
||||||
if ( i != this->ImportedTargets.end() )
|
|
||||||
{
|
|
||||||
return i->second;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -2622,18 +2649,6 @@ cmGlobalGenerator::GetTargetDirectDepends(cmGeneratorTarget const* target)
|
||||||
return this->TargetDependencies[target];
|
return this->TargetDependencies[target];
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmGlobalGenerator::AddTarget(cmTarget* t)
|
|
||||||
{
|
|
||||||
if(t->IsImported())
|
|
||||||
{
|
|
||||||
this->ImportedTargets[t->GetName()] = t;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->TotalTargets[t->GetName()] = t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool cmGlobalGenerator::IsReservedTarget(std::string const& name)
|
bool cmGlobalGenerator::IsReservedTarget(std::string const& name)
|
||||||
{
|
{
|
||||||
// The following is a list of targets reserved
|
// The following is a list of targets reserved
|
||||||
|
@ -2939,17 +2954,20 @@ void cmGlobalGenerator::WriteSummary()
|
||||||
fname += "/TargetDirectories.txt";
|
fname += "/TargetDirectories.txt";
|
||||||
cmGeneratedFileStream fout(fname.c_str());
|
cmGeneratedFileStream fout(fname.c_str());
|
||||||
|
|
||||||
// Generate summary information files for each target.
|
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
|
||||||
for(TargetMap::const_iterator ti =
|
|
||||||
this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti)
|
|
||||||
{
|
{
|
||||||
if ((ti->second)->GetType() == cmState::INTERFACE_LIBRARY)
|
std::vector<cmGeneratorTarget*> tgts =
|
||||||
|
this->LocalGenerators[i]->GetGeneratorTargets();
|
||||||
|
for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin();
|
||||||
|
it != tgts.end(); ++it)
|
||||||
{
|
{
|
||||||
continue;
|
if ((*it)->GetType() == cmState::INTERFACE_LIBRARY)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
this->WriteSummary(*it);
|
||||||
|
fout << (*it)->GetSupportDirectory() << "\n";
|
||||||
}
|
}
|
||||||
cmGeneratorTarget* gt = this->GetGeneratorTarget(ti->second);
|
|
||||||
this->WriteSummary(gt);
|
|
||||||
fout << gt->GetSupportDirectory() << "\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -280,8 +280,6 @@ public:
|
||||||
std::set<std::string> const& GetDirectoryContent(std::string const& dir,
|
std::set<std::string> const& GetDirectoryContent(std::string const& dir,
|
||||||
bool needDisk = true);
|
bool needDisk = true);
|
||||||
|
|
||||||
void AddTarget(cmTarget* t);
|
|
||||||
|
|
||||||
static bool IsReservedTarget(std::string const& name);
|
static bool IsReservedTarget(std::string const& name);
|
||||||
|
|
||||||
virtual const char* GetAllTargetName() const { return "ALL_BUILD"; }
|
virtual const char* GetAllTargetName() const { return "ALL_BUILD"; }
|
||||||
|
@ -439,9 +437,10 @@ protected:
|
||||||
#else
|
#else
|
||||||
typedef std::map<std::string,cmTarget *> TargetMap;
|
typedef std::map<std::string,cmTarget *> TargetMap;
|
||||||
#endif
|
#endif
|
||||||
TargetMap TotalTargets;
|
|
||||||
TargetMap AliasTargets;
|
TargetMap AliasTargets;
|
||||||
TargetMap ImportedTargets;
|
|
||||||
|
cmTarget* FindTargetImpl(std::string const& name) const;
|
||||||
|
cmTarget* FindImportedTargetImpl(std::string const& name) const;
|
||||||
|
|
||||||
const char* GetPredefinedTargetsFolder();
|
const char* GetPredefinedTargetsFolder();
|
||||||
virtual bool UseFolderProperty();
|
virtual bool UseFolderProperty();
|
||||||
|
|
|
@ -354,14 +354,18 @@ void cmGlobalVisualStudio8Generator::AddExtraIDETargets()
|
||||||
cmGlobalVisualStudio7Generator::AddExtraIDETargets();
|
cmGlobalVisualStudio7Generator::AddExtraIDETargets();
|
||||||
if(this->AddCheckTarget())
|
if(this->AddCheckTarget())
|
||||||
{
|
{
|
||||||
// All targets depend on the build-system check target.
|
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
|
||||||
for(TargetMap::const_iterator
|
|
||||||
ti = this->TotalTargets.begin();
|
|
||||||
ti != this->TotalTargets.end(); ++ti)
|
|
||||||
{
|
{
|
||||||
if(ti->first != CMAKE_CHECK_BUILD_SYSTEM_TARGET)
|
std::vector<cmGeneratorTarget*> tgts =
|
||||||
|
this->LocalGenerators[i]->GetGeneratorTargets();
|
||||||
|
// All targets depend on the build-system check target.
|
||||||
|
for(std::vector<cmGeneratorTarget*>::iterator ti = tgts.begin();
|
||||||
|
ti != tgts.end(); ++ti)
|
||||||
{
|
{
|
||||||
ti->second->AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET);
|
if((*ti)->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET)
|
||||||
|
{
|
||||||
|
(*ti)->Target->AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1362,12 +1362,17 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmGlobalXCodeGenerator::ForceLinkerLanguages()
|
void cmGlobalXCodeGenerator::ForceLinkerLanguages()
|
||||||
{
|
{
|
||||||
// This makes sure all targets link using the proper language.
|
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
|
||||||
for(TargetMap::const_iterator
|
|
||||||
ti = this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti)
|
|
||||||
{
|
{
|
||||||
cmGeneratorTarget* gt = this->GetGeneratorTarget(ti->second);
|
std::vector<cmGeneratorTarget*> tgts =
|
||||||
this->ForceLinkerLanguage(gt);
|
this->LocalGenerators[i]->GetGeneratorTargets();
|
||||||
|
// All targets depend on the build-system check target.
|
||||||
|
for(std::vector<cmGeneratorTarget*>::const_iterator ti = tgts.begin();
|
||||||
|
ti != tgts.end(); ++ti)
|
||||||
|
{
|
||||||
|
// This makes sure all targets link using the proper language.
|
||||||
|
this->ForceLinkerLanguage(*ti);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2096,7 +2096,6 @@ cmMakefile::AddNewTarget(cmState::TargetType type, const std::string& name)
|
||||||
cmTarget& target = it->second;
|
cmTarget& target = it->second;
|
||||||
target.SetType(type, name);
|
target.SetType(type, name);
|
||||||
target.SetMakefile(this);
|
target.SetMakefile(this);
|
||||||
this->GetGlobalGenerator()->AddTarget(&it->second);
|
|
||||||
return &it->second;
|
return &it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4183,15 +4182,11 @@ cmMakefile::AddImportedTarget(const std::string& name,
|
||||||
// Create the target.
|
// Create the target.
|
||||||
cmsys::auto_ptr<cmTarget> target(new cmTarget);
|
cmsys::auto_ptr<cmTarget> target(new cmTarget);
|
||||||
target->SetType(type, name);
|
target->SetType(type, name);
|
||||||
target->MarkAsImported();
|
target->MarkAsImported(global);
|
||||||
target->SetMakefile(this);
|
target->SetMakefile(this);
|
||||||
|
|
||||||
// Add to the set of available imported targets.
|
// Add to the set of available imported targets.
|
||||||
this->ImportedTargets[name] = target.get();
|
this->ImportedTargets[name] = target.get();
|
||||||
if(global)
|
|
||||||
{
|
|
||||||
this->GetGlobalGenerator()->AddTarget(target.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Transfer ownership to this cmMakefile object.
|
// Transfer ownership to this cmMakefile object.
|
||||||
this->ImportedTargetsOwned.push_back(target.get());
|
this->ImportedTargetsOwned.push_back(target.get());
|
||||||
|
|
|
@ -63,6 +63,7 @@ cmTarget::cmTarget()
|
||||||
this->IsAndroid = false;
|
this->IsAndroid = false;
|
||||||
this->IsApple = false;
|
this->IsApple = false;
|
||||||
this->IsImportedTarget = false;
|
this->IsImportedTarget = false;
|
||||||
|
this->ImportedGloballyVisible = false;
|
||||||
this->BuildInterfaceIncludesAppended = false;
|
this->BuildInterfaceIncludesAppended = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1505,9 +1506,10 @@ void cmTarget::CheckProperty(const std::string& prop,
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmTarget::MarkAsImported()
|
void cmTarget::MarkAsImported(bool global)
|
||||||
{
|
{
|
||||||
this->IsImportedTarget = true;
|
this->IsImportedTarget = true;
|
||||||
|
this->ImportedGloballyVisible = global;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
|
@ -75,7 +75,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void SetType(cmState::TargetType f, const std::string& name);
|
void SetType(cmState::TargetType f, const std::string& name);
|
||||||
|
|
||||||
void MarkAsImported();
|
void MarkAsImported(bool global = false);
|
||||||
|
|
||||||
///! Set/Get the name of the target
|
///! Set/Get the name of the target
|
||||||
const std::string& GetName() const {return this->Name;}
|
const std::string& GetName() const {return this->Name;}
|
||||||
|
@ -186,6 +186,8 @@ public:
|
||||||
void CheckProperty(const std::string& prop, cmMakefile* context) const;
|
void CheckProperty(const std::string& prop, cmMakefile* context) const;
|
||||||
|
|
||||||
bool IsImported() const {return this->IsImportedTarget;}
|
bool IsImported() const {return this->IsImportedTarget;}
|
||||||
|
bool IsImportedGloballyVisible() const
|
||||||
|
{ return this->ImportedGloballyVisible; }
|
||||||
|
|
||||||
// Get the properties
|
// Get the properties
|
||||||
cmPropertyMap &GetProperties() const { return this->Properties; }
|
cmPropertyMap &GetProperties() const { return this->Properties; }
|
||||||
|
@ -349,6 +351,7 @@ private:
|
||||||
bool IsAndroid;
|
bool IsAndroid;
|
||||||
bool IsApple;
|
bool IsApple;
|
||||||
bool IsImportedTarget;
|
bool IsImportedTarget;
|
||||||
|
bool ImportedGloballyVisible;
|
||||||
bool BuildInterfaceIncludesAppended;
|
bool BuildInterfaceIncludesAppended;
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
bool LinkLibrariesForVS6Analyzed;
|
bool LinkLibrariesForVS6Analyzed;
|
||||||
|
|
Loading…
Reference in New Issue