Commit 4f1c71fd authored by Stephen Kelly's avatar Stephen Kelly

cmTarget: Add all sources traced from custom commands at once.

The AddSource method accepts one file and tries to avoiding adding
it to the sources-list of the target if it already exists.  This
involves creating many cmSourceFileLocation objects for matching
on existing files, which is an expensive operation.

Avoid the searching algorithm by appending the new sources as one
group.  Generate-time processing of source files will ensure

Add a new AddTracedSources for this purpose.  The existing
AddSources method must process the input for policy CMP0049, but
as these source filenames come from cmSourceFile::GetFullPath(),
we can forego that extra processing.
parent b1c3ae33
......@@ -610,6 +610,7 @@ private:
std::set<cmSourceFile*> SourcesQueued;
typedef std::map<std::string, cmSourceFile*> NameMapType;
NameMapType NameMap;
std::vector<std::string> NewSources;
void QueueSource(cmSourceFile* sf);
void FollowName(std::string const& name);
......@@ -698,6 +699,8 @@ void cmTargetTraceDependencies::Trace()
this->CurrentEntry = 0;
......@@ -707,8 +710,8 @@ void cmTargetTraceDependencies::QueueSource(cmSourceFile* sf)
// Make sure this file is in the target.
// Make sure this file is in the target at the end.
......@@ -849,6 +849,33 @@ void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files,
void cmTarget::AddTracedSources(std::vector<std::string> const& srcs)
std::string srcFiles;
const char* sep = "";
for(std::vector<std::string>::const_iterator i = srcs.begin();
i != srcs.end(); ++i)
std::string filename = *i;
srcFiles += sep;
srcFiles += filename;
sep = ";";
if (!srcFiles.empty())
this->LinkImplementationLanguageIsContextDependent = true;
cmListFileBacktrace lfbt;
cmGeneratorExpression ge(lfbt);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(srcFiles);
new cmTargetInternals::TargetPropertyEntry(cge));
void cmTarget::AddSources(std::vector<std::string> const& srcs)
......@@ -144,6 +144,7 @@ public:
* Add sources to the target.
void AddSources(std::vector<std::string> const& srcs);
void AddTracedSources(std::vector<std::string> const& srcs);
cmSourceFile* AddSourceCMP0049(const std::string& src);
cmSourceFile* AddSource(const std::string& src);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment