From eb163f37d449af27fe8446c5d8d632aa295b6428 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Apr 2014 17:45:28 +0200 Subject: 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. --- Source/cmTarget.cxx | 48 +++++++++++++++++++++++++++++++++++++++--------- Source/cmTarget.h | 2 ++ 2 files changed, 41 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 &files, //---------------------------------------------------------------------------- void cmTarget::AddSources(std::vector const& srcs) { + std::string srcFiles; + const char* sep = ""; for(std::vector::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 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); } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index da032a5..a8ac57f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -752,6 +752,8 @@ private: void ComputeLinkClosure(const std::string& config, LinkClosure& lc, cmTarget const* head) const; + std::string ProcessSourceItemCMP0049(const std::string& s); + void ClearLinkMaps(); void MaybeInvalidatePropertyCache(const std::string& prop); -- cgit v0.12