From 3b3622305bb950f16f238f030c8f32786ad3511a Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Wed, 7 Sep 2016 20:40:18 +0200 Subject: [PATCH 1/3] cmGeneratorTarget: don't clear container in destructor It will be destroyed anyway. This also makes it easier to search for places where containers are atually cleared in order to be recomputed. --- Source/cmGeneratorTarget.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index ee2907cab..25917f8b5 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -327,7 +327,6 @@ cmGeneratorTarget::~cmGeneratorTarget() cmDeleteAll(this->CompileDefinitionsEntries); cmDeleteAll(this->SourceEntries); cmDeleteAll(this->LinkInformation); - this->LinkInformation.clear(); } cmLocalGenerator* cmGeneratorTarget::GetLocalGenerator() const From 52052ef88b6f46a12c8430395ae8b419971fcb35 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Wed, 7 Sep 2016 21:03:18 +0200 Subject: [PATCH 2/3] cmGeneratorTarget: use erase-unique instead of reinitialization Just to make it easier to find places where containers are cleared in order to be recomputed. --- Source/cmGeneratorTarget.cxx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 25917f8b5..4baec0306 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -839,14 +839,10 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory( &dagChecker, result, excludeImported); } - std::set unique; - for (std::vector::iterator li = result.begin(); - li != result.end(); ++li) { - cmSystemTools::ConvertToUnixSlashes(*li); - unique.insert(*li); - } - result.clear(); - result.insert(result.end(), unique.begin(), unique.end()); + std::for_each(result.begin(), result.end(), + cmSystemTools::ConvertToUnixSlashes); + std::sort(result.begin(), result.end()); + result.erase(std::unique(result.begin(), result.end()), result.end()); IncludeCacheType::value_type entry(config_upper, result); iter = this->SystemIncludesCache.insert(entry).first; From cc6b948e5ea86996fe65014ce8f97bf92b46e4c0 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Wed, 7 Sep 2016 21:14:29 +0200 Subject: [PATCH 3/3] cmGeneratorTarget: factor out common part of AddSources commands --- Source/cmGeneratorTarget.cxx | 19 ++++++++----------- Source/cmGeneratorTarget.h | 2 ++ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4baec0306..7dd8e7fac 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -468,9 +468,8 @@ std::string cmGeneratorTarget::GetOutputName(const std::string& config, return i->second; } -void cmGeneratorTarget::AddSource(const std::string& src) +void cmGeneratorTarget::AddSourceCommon(const std::string& src) { - this->Target->AddSource(src); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmGeneratorExpression ge(lfbt); CM_AUTO_PTR cge = ge.Parse(src); @@ -480,19 +479,17 @@ void cmGeneratorTarget::AddSource(const std::string& src) this->LinkImplementationLanguageIsContextDependent = true; } +void cmGeneratorTarget::AddSource(const std::string& src) +{ + this->Target->AddSource(src); + this->AddSourceCommon(src); +} + void cmGeneratorTarget::AddTracedSources(std::vector const& srcs) { this->Target->AddTracedSources(srcs); if (!srcs.empty()) { - std::string srcFiles = cmJoin(srcs, ";"); - this->SourceFilesMap.clear(); - this->LinkImplementationLanguageIsContextDependent = true; - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - CM_AUTO_PTR cge = ge.Parse(srcFiles); - cge->SetEvaluateForBuildsystem(true); - this->SourceEntries.push_back( - new cmGeneratorTarget::TargetPropertyEntry(cge)); + this->AddSourceCommon(cmJoin(srcs, ";")); } } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 173f15dc4..715220e5d 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -540,6 +540,8 @@ public: std::string GetFortranModuleDirectory() const; private: + void AddSourceCommon(const std::string& src); + std::string CreateFortranModuleDirectory() const; mutable bool FortranModuleDirectoryCreated; mutable std::string FortranModuleDirectory;