diff options
author | Stephen Kelly <steveire@gmail.com> | 2014-04-08 23:32:14 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2014-04-09 08:37:00 (GMT) |
commit | 4f1c71fdd25f33bd0cdeb2b705723db02f8fddf4 (patch) | |
tree | 251f875fe9bfc02f9cfc68b470edd600bba945e5 /Source/cmTarget.cxx | |
parent | b1c3ae33eacb55a54a7ce28c5a5d6aa8903fbac2 (diff) | |
download | CMake-4f1c71fdd25f33bd0cdeb2b705723db02f8fddf4.zip CMake-4f1c71fdd25f33bd0cdeb2b705723db02f8fddf4.tar.gz CMake-4f1c71fdd25f33bd0cdeb2b705723db02f8fddf4.tar.bz2 |
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
uniqueness.
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.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r-- | Source/cmTarget.cxx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 4903f8b..1f8cddb 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -850,6 +850,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->Internal->SourceFilesMap.clear(); + this->LinkImplementationLanguageIsContextDependent = true; + cmListFileBacktrace lfbt; + this->Makefile->GetBacktrace(lfbt); + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(srcFiles); + cge->SetEvaluateForBuildsystem(true); + this->Internal->SourceEntries.push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); + } +} + +//---------------------------------------------------------------------------- void cmTarget::AddSources(std::vector<std::string> const& srcs) { std::string srcFiles; |