diff options
author | Stephen Kelly <steveire@gmail.com> | 2014-04-04 15:45:28 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2014-04-06 08:02:34 (GMT) |
commit | eb163f37d449af27fe8446c5d8d632aa295b6428 (patch) | |
tree | 2d66790f6c74daa60365ebcdf0b2eb8adc877aa4 /Source/cmTarget.cxx | |
parent | 19b7c22d020a3b1bf26065beb33b0f2f499cd1ad (diff) | |
download | CMake-eb163f37d449af27fe8446c5d8d632aa295b6428.zip CMake-eb163f37d449af27fe8446c5d8d632aa295b6428.tar.gz CMake-eb163f37d449af27fe8446c5d8d632aa295b6428.tar.bz2 |
cmTarget: Extract a ProcessSourceItemCMP0049 method.
Avoid calling AddSource for each src filename. That involves
checking each entry for uniqueness and creating a separate
generator expression for each one.
Instead, add a single entry for the list of sources. The source
files are passed through a uniqueness filter at generate-time, so
duplicates don't matter so much.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r-- | Source/cmTarget.cxx | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b6bb2d3..22be57f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -812,23 +812,41 @@ void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files, //---------------------------------------------------------------------------- void cmTarget::AddSources(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) { - const char* src = i->c_str(); - if(src[0] == '$' && src[1] == '<') - { - this->AddSource(src); - } - else + std::string filename = *i; + const char* src = filename.c_str(); + + if(!(src[0] == '$' && src[1] == '<')) { - this->AddSourceCMP0049(src); + filename = this->ProcessSourceItemCMP0049(filename); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + this->Makefile->GetOrCreateSource(filename); } + srcFiles += sep; + srcFiles += filename; + sep = ";"; + } + if (!srcFiles.empty()) + { + 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)); } } //---------------------------------------------------------------------------- -cmSourceFile* cmTarget::AddSourceCMP0049(const std::string& s) +std::string cmTarget::ProcessSourceItemCMP0049(const std::string& s) { std::string src = s; @@ -863,10 +881,22 @@ cmSourceFile* cmTarget::AddSourceCMP0049(const std::string& s) this->Makefile->IssueMessage(messageType, e.str()); if (messageType == cmake::FATAL_ERROR) { - return 0; + return ""; } } } + return src; +} + +//---------------------------------------------------------------------------- +cmSourceFile* cmTarget::AddSourceCMP0049(const std::string& s) +{ + std::string src = this->ProcessSourceItemCMP0049(s); + + if (cmSystemTools::GetErrorOccuredFlag()) + { + return 0; + } return this->AddSource(src); } |