cmTarget: Make GetSourceFiles populate an out-vector parameter.

In a future patch, this will also be populated with extra
sources from the linked dependencies.
This commit is contained in:
Stephen Kelly 2013-07-14 18:22:57 +02:00
parent 38de54cf6f
commit 531e40b95e
18 changed files with 54 additions and 33 deletions

View File

@ -398,7 +398,8 @@ void cmExtraCodeBlocksGenerator
case cmTarget::OBJECT_LIBRARY: case cmTarget::OBJECT_LIBRARY:
case cmTarget::UTILITY: // can have sources since 2.6.3 case cmTarget::UTILITY: // can have sources since 2.6.3
{ {
const std::vector<cmSourceFile*>&sources=ti->second.GetSourceFiles(); std::vector<cmSourceFile*> sources;
ti->second.GetSourceFiles(sources);
for (std::vector<cmSourceFile*>::const_iterator si=sources.begin(); for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
si!=sources.end(); si++) si!=sources.end(); si++)
{ {

View File

@ -559,7 +559,8 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(
std::vector<cmSourceGroup> sourceGroups=makefile->GetSourceGroups(); std::vector<cmSourceGroup> sourceGroups=makefile->GetSourceGroups();
// get the files from the source lists then add them to the groups // get the files from the source lists then add them to the groups
cmTarget* tgt = const_cast<cmTarget*>(&ti->second); cmTarget* tgt = const_cast<cmTarget*>(&ti->second);
std::vector<cmSourceFile*>const & files = tgt->GetSourceFiles(); std::vector<cmSourceFile*> files;
tgt->GetSourceFiles(files);
for(std::vector<cmSourceFile*>::const_iterator sfIt = files.begin(); for(std::vector<cmSourceFile*>::const_iterator sfIt = files.begin();
sfIt != files.end(); sfIt != files.end();
sfIt++) sfIt++)

View File

@ -237,7 +237,8 @@ void cmExtraSublimeTextGenerator::
{ {
cmGeneratorTarget *gtgt = this->GlobalGenerator cmGeneratorTarget *gtgt = this->GlobalGenerator
->GetGeneratorTarget(target); ->GetGeneratorTarget(target);
std::vector<cmSourceFile*> const& sourceFiles = target->GetSourceFiles(); std::vector<cmSourceFile*> sourceFiles;
target->GetSourceFiles(sourceFiles);
std::vector<cmSourceFile*>::const_iterator sourceFilesEnd = std::vector<cmSourceFile*>::const_iterator sourceFilesEnd =
sourceFiles.end(); sourceFiles.end();
for (std::vector<cmSourceFile*>::const_iterator iter = for (std::vector<cmSourceFile*>::const_iterator iter =

View File

@ -132,8 +132,8 @@ void cmFLTKWrapUICommand::FinalPass()
cmSystemTools::Message(msg.c_str(),"Warning"); cmSystemTools::Message(msg.c_str(),"Warning");
return; return;
} }
std::vector<cmSourceFile*> const& srcs = std::vector<cmSourceFile*> srcs;
target->GetSourceFiles(); target->GetSourceFiles(srcs);
bool found = false; bool found = false;
for (unsigned int i = 0; i < srcs.size(); ++i) for (unsigned int i = 0; i < srcs.size(); ++i)
{ {

View File

@ -284,9 +284,9 @@ bool cmGeneratorTarget::GetPropertyAsBool(const char *prop) const
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::vector<cmSourceFile*> const& cmGeneratorTarget::GetSourceFiles() const void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const
{ {
return this->Target->GetSourceFiles(); this->Target->GetSourceFiles(files);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -298,7 +298,8 @@ void cmGeneratorTarget::ClassifySources()
bool isObjLib = targetType == cmTarget::OBJECT_LIBRARY; bool isObjLib = targetType == cmTarget::OBJECT_LIBRARY;
std::vector<cmSourceFile*> badObjLib; std::vector<cmSourceFile*> badObjLib;
std::vector<cmSourceFile*> const& sources = this->Target->GetSourceFiles(); std::vector<cmSourceFile*> sources;
this->Target->GetSourceFiles(sources);
for(std::vector<cmSourceFile*>::const_iterator si = sources.begin(); for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
si != sources.end(); ++si) si != sources.end(); ++si)
{ {
@ -496,7 +497,8 @@ cmTargetTraceDependencies
this->CurrentEntry = 0; this->CurrentEntry = 0;
// Queue all the source files already specified for the target. // Queue all the source files already specified for the target.
std::vector<cmSourceFile*> const& sources = this->Target->GetSourceFiles(); std::vector<cmSourceFile*> sources;
this->Target->GetSourceFiles(sources);
for(std::vector<cmSourceFile*>::const_iterator si = sources.begin(); for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
si != sources.end(); ++si) si != sources.end(); ++si)
{ {

View File

@ -30,7 +30,7 @@ public:
const char *GetName() const; const char *GetName() const;
const char *GetProperty(const char *prop) const; const char *GetProperty(const char *prop) const;
bool GetPropertyAsBool(const char *prop) const; bool GetPropertyAsBool(const char *prop) const;
std::vector<cmSourceFile*> const& GetSourceFiles() const; void GetSourceFiles(std::vector<cmSourceFile*>& files) const;
void GetObjectSources(std::vector<cmSourceFile*> &) const; void GetObjectSources(std::vector<cmSourceFile*> &) const;
const std::string& GetObjectName(cmSourceFile const* file); const std::string& GetObjectName(cmSourceFile const* file);

View File

@ -2884,7 +2884,8 @@ void cmGlobalGenerator::WriteSummary(cmTarget* target)
// List the source files with any per-source labels. // List the source files with any per-source labels.
fout << "# Source files and their labels\n"; fout << "# Source files and their labels\n";
std::vector<cmSourceFile*> const& sources = target->GetSourceFiles(); std::vector<cmSourceFile*> sources;
target->GetSourceFiles(sources);
for(std::vector<cmSourceFile*>::const_iterator si = sources.begin(); for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
si != sources.end(); ++si) si != sources.end(); ++si)
{ {

View File

@ -138,7 +138,8 @@ bool cmGlobalKdevelopGenerator
for (cmTargets::iterator ti = targets.begin(); for (cmTargets::iterator ti = targets.begin();
ti != targets.end(); ti++) ti != targets.end(); ti++)
{ {
const std::vector<cmSourceFile*>& sources=ti->second.GetSourceFiles(); std::vector<cmSourceFile*> sources;
ti->second.GetSourceFiles(sources);
for (std::vector<cmSourceFile*>::const_iterator si=sources.begin(); for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
si!=sources.end(); si++) si!=sources.end(); si++)
{ {

View File

@ -991,7 +991,8 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
} }
// organize the sources // organize the sources
std::vector<cmSourceFile*> classes = cmtarget.GetSourceFiles(); std::vector<cmSourceFile*> classes;
cmtarget.GetSourceFiles(classes);
std::sort(classes.begin(), classes.end(), cmSourceFilePathCompare()); std::sort(classes.begin(), classes.end(), cmSourceFilePathCompare());
std::vector<cmXCodeObject*> externalObjFiles; std::vector<cmXCodeObject*> externalObjFiles;
@ -1360,7 +1361,8 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases,
postbuild.push_back(command); postbuild.push_back(command);
} }
std::vector<cmSourceFile*>const &classes = cmtarget.GetSourceFiles(); std::vector<cmSourceFile*> classes;
cmtarget.GetSourceFiles(classes);
// add all the sources // add all the sources
std::vector<cmCustomCommand> commands; std::vector<cmCustomCommand> commands;
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
@ -2442,7 +2444,8 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget)
// Add source files without build rules for editing convenience. // Add source files without build rules for editing convenience.
if(cmtarget.GetType() == cmTarget::UTILITY) if(cmtarget.GetType() == cmTarget::UTILITY)
{ {
std::vector<cmSourceFile*> const& sources = cmtarget.GetSourceFiles(); std::vector<cmSourceFile*> sources;
cmtarget.GetSourceFiles(sources);
for(std::vector<cmSourceFile*>::const_iterator i = sources.begin(); for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
i != sources.end(); ++i) i != sources.end(); ++i)
{ {
@ -2945,7 +2948,8 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
cmtarget.AddSourceFile(sf); cmtarget.AddSourceFile(sf);
} }
std::vector<cmSourceFile*> classes = cmtarget.GetSourceFiles(); std::vector<cmSourceFile*> classes;
cmtarget.GetSourceFiles(classes);
// Put cmSourceFile instances in proper groups: // Put cmSourceFile instances in proper groups:
for(std::vector<cmSourceFile*>::const_iterator s = classes.begin(); for(std::vector<cmSourceFile*>::const_iterator s = classes.begin();

View File

@ -657,7 +657,8 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang,
cmStdString objs; cmStdString objs;
std::vector<std::string> objVector; std::vector<std::string> objVector;
// Add all the sources outputs to the depends of the target // Add all the sources outputs to the depends of the target
std::vector<cmSourceFile*> const& classes = target.GetSourceFiles(); std::vector<cmSourceFile*> classes;
target.GetSourceFiles(classes);
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); ++i) i != classes.end(); ++i)
{ {
@ -1631,7 +1632,8 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
if(this->Makefile->IsOn("WIN32") && if(this->Makefile->IsOn("WIN32") &&
!(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW"))) !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW")))
{ {
const std::vector<cmSourceFile*>& sources = target->GetSourceFiles(); std::vector<cmSourceFile*> sources;
target->GetSourceFiles(sources);
for(std::vector<cmSourceFile*>::const_iterator i = sources.begin(); for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
i != sources.end(); ++i) i != sources.end(); ++i)
{ {

View File

@ -314,7 +314,8 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups(); std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
// get the classes from the source lists then add them to the groups // get the classes from the source lists then add them to the groups
std::vector<cmSourceFile*> const & classes = target.GetSourceFiles(); std::vector<cmSourceFile*> classes;
target.GetSourceFiles(classes);
// now all of the source files have been properly assigned to the target // now all of the source files have been properly assigned to the target
// now stick them into source groups using the reg expressions // now stick them into source groups using the reg expressions

View File

@ -1381,7 +1381,8 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
// get the classes from the source lists then add them to the groups // get the classes from the source lists then add them to the groups
this->ModuleDefinitionFile = ""; this->ModuleDefinitionFile = "";
std::vector<cmSourceFile*>const & classes = target.GetSourceFiles(); std::vector<cmSourceFile*> classes;
target.GetSourceFiles(classes);
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); i++) i != classes.end(); i++)
{ {

View File

@ -1152,8 +1152,8 @@ cmMakefileTargetGenerator
::DriveCustomCommands(std::vector<std::string>& depends) ::DriveCustomCommands(std::vector<std::string>& depends)
{ {
// Depend on all custom command outputs. // Depend on all custom command outputs.
const std::vector<cmSourceFile*>& sources = std::vector<cmSourceFile*> sources;
this->Target->GetSourceFiles(); this->Target->GetSourceFiles(sources);
for(std::vector<cmSourceFile*>::const_iterator source = sources.begin(); for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
source != sources.end(); ++source) source != sources.end(); ++source)
{ {

View File

@ -42,8 +42,8 @@ void cmNinjaUtilityTargetGenerator::Generate()
} }
} }
const std::vector<cmSourceFile*>& sources = std::vector<cmSourceFile*> sources;
this->GetTarget()->GetSourceFiles(); this->GetTarget()->GetSourceFiles(sources);
for(std::vector<cmSourceFile*>::const_iterator source = sources.begin(); for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
source != sources.end(); ++source) source != sources.end(); ++source)
{ {

View File

@ -451,7 +451,8 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target,
const char* sepFiles = ""; const char* sepFiles = "";
const char* sepHeaders = ""; const char* sepHeaders = "";
const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles(); std::vector<cmSourceFile*> srcFiles;
target->GetSourceFiles(srcFiles);
std::string skip_moc; std::string skip_moc;
const char *sep = ""; const char *sep = "";
@ -643,7 +644,8 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
const char *qtUic = makefile->GetSafeDefinition("QT_UIC_EXECUTABLE"); const char *qtUic = makefile->GetSafeDefinition("QT_UIC_EXECUTABLE");
makefile->AddDefinition("_qt_uic_executable", qtUic); makefile->AddDefinition("_qt_uic_executable", qtUic);
const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles(); std::vector<cmSourceFile*> srcFiles;
target->GetSourceFiles(srcFiles);
std::string skip_uic; std::string skip_uic;
const char *sep = ""; const char *sep = "";
@ -809,7 +811,8 @@ void cmQtAutoGenerators::InitializeAutoRccTarget(cmTarget* target)
{ {
cmMakefile *makefile = target->GetMakefile(); cmMakefile *makefile = target->GetMakefile();
const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles(); std::vector<cmSourceFile*> srcFiles;
target->GetSourceFiles(srcFiles);
std::vector<cmSourceFile*> newFiles; std::vector<cmSourceFile*> newFiles;
@ -855,7 +858,8 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
const char* sepRccFiles = ""; const char* sepRccFiles = "";
cmMakefile *makefile = target->GetMakefile(); cmMakefile *makefile = target->GetMakefile();
const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles(); std::vector<cmSourceFile*> srcFiles;
target->GetSourceFiles(srcFiles);
std::string rccFileFiles; std::string rccFileFiles;
std::string rccFileOptions; std::string rccFileOptions;

View File

@ -530,9 +530,9 @@ bool cmTarget::FindSourceFiles()
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::vector<cmSourceFile*> const& cmTarget::GetSourceFiles() const void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const
{ {
return this->SourceFiles; files = this->SourceFiles;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -673,7 +673,8 @@ void cmTarget::ConstructSourceFileFlags() const
// Handle the MACOSX_PACKAGE_LOCATION property on source files that // Handle the MACOSX_PACKAGE_LOCATION property on source files that
// were not listed in one of the other lists. // were not listed in one of the other lists.
std::vector<cmSourceFile*> const& sources = this->GetSourceFiles(); std::vector<cmSourceFile*> sources;
this->GetSourceFiles(sources);
for(std::vector<cmSourceFile*>::const_iterator si = sources.begin(); for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
si != sources.end(); ++si) si != sources.end(); ++si)
{ {

View File

@ -132,7 +132,7 @@ 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() const; void GetSourceFiles(std::vector<cmSourceFile*> &files) const;
void AddSourceFile(cmSourceFile* sf); void AddSourceFile(cmSourceFile* sf);
std::vector<std::string> const& GetObjectLibraries() const std::vector<std::string> const& GetObjectLibraries() const
{ {

View File

@ -699,7 +699,8 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
// collect up group information // collect up group information
std::vector<cmSourceGroup> sourceGroups = std::vector<cmSourceGroup> sourceGroups =
this->Makefile->GetSourceGroups(); this->Makefile->GetSourceGroups();
std::vector<cmSourceFile*> classes = this->Target->GetSourceFiles(); std::vector<cmSourceFile*> classes;
this->Target->GetSourceFiles(classes);
std::set<cmSourceGroup*> groupsUsed; std::set<cmSourceGroup*> groupsUsed;
for(std::vector<cmSourceFile*>::const_iterator s = classes.begin(); for(std::vector<cmSourceFile*>::const_iterator s = classes.begin();