Cleanup cmTarget source file list representation

This teaches cmTarget to use a set of cmSourceFile pointers to guarantee
unique insertion of source files in a target.  The order of insertion is
still preserved in the SourceFiles vector.
This commit is contained in:
Brad King 2009-09-04 12:39:05 -04:00
parent 053519b390
commit 4eb5f1bef6
2 changed files with 19 additions and 11 deletions

View File

@ -1089,7 +1089,6 @@ private:
cmGlobalGenerator* GlobalGenerator; cmGlobalGenerator* GlobalGenerator;
std::queue<cmStdString> DependencyQueue; std::queue<cmStdString> DependencyQueue;
std::set<cmStdString> DependenciesQueued; std::set<cmStdString> DependenciesQueued;
std::set<cmSourceFile*> TargetSources;
void QueueOnce(std::string const& name); void QueueOnce(std::string const& name);
void QueueOnce(std::vector<std::string> const& names); void QueueOnce(std::vector<std::string> const& names);
@ -1120,9 +1119,6 @@ cmTargetTraceDependencies
// Queue the dependencies of the source file in case they are // Queue the dependencies of the source file in case they are
// generated. // generated.
this->QueueDependencies(*si); this->QueueDependencies(*si);
// Track the sources already known to the target.
this->TargetSources.insert(*si);
} }
// Queue the VS project file to check dependencies on the rule to // Queue the VS project file to check dependencies on the rule to
@ -1156,10 +1152,7 @@ void cmTargetTraceDependencies::Trace()
this->QueueDependencies(sf); this->QueueDependencies(sf);
// Make sure this file is in the target. // Make sure this file is in the target.
if(this->TargetSources.insert(sf).second) this->Target->AddSourceFile(sf);
{
this->Target->AddSourceFile(sf);
}
} }
} }
} }
@ -1330,6 +1323,21 @@ bool cmTarget::FindSourceFiles()
return true; return true;
} }
//----------------------------------------------------------------------------
std::vector<cmSourceFile*> const& cmTarget::GetSourceFiles()
{
return this->SourceFiles;
}
//----------------------------------------------------------------------------
void cmTarget::AddSourceFile(cmSourceFile* sf)
{
if(this->SourceFileSet.insert(sf).second)
{
this->SourceFiles.push_back(sf);
}
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmTarget::AddSources(std::vector<std::string> const& srcs) void cmTarget::AddSources(std::vector<std::string> const& srcs)
{ {

View File

@ -119,9 +119,8 @@ public:
/** /**
* Get the list of the source files used by this target * Get the list of the source files used by this target
*/ */
std::vector<cmSourceFile*> const &GetSourceFiles() std::vector<cmSourceFile*> const& GetSourceFiles();
{return this->SourceFiles;} void AddSourceFile(cmSourceFile* sf);
void AddSourceFile(cmSourceFile* sf) { this->SourceFiles.push_back(sf); }
/** /**
* Flags for a given source file as used in this target. Typically assigned * Flags for a given source file as used in this target. Typically assigned
@ -531,6 +530,7 @@ private:
std::vector<cmCustomCommand> PostBuildCommands; std::vector<cmCustomCommand> PostBuildCommands;
TargetType TargetTypeValue; TargetType TargetTypeValue;
std::vector<cmSourceFile*> SourceFiles; std::vector<cmSourceFile*> SourceFiles;
std::set<cmSourceFile*> SourceFileSet;
LinkLibraryVectorType LinkLibraries; LinkLibraryVectorType LinkLibraries;
LinkLibraryVectorType PrevLinkedLibraries; LinkLibraryVectorType PrevLinkedLibraries;
bool LinkLibrariesAnalyzed; bool LinkLibrariesAnalyzed;