From a8429a402da4aeb717f4af234c8d14d1c4e10ed7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 5 Aug 2015 17:37:51 +0200 Subject: [PATCH] cmTarget: Split storage of link implementation from backtraces. --- Source/cmListFileCache.h | 9 --------- Source/cmTarget.cxx | 36 +++++++++++++++--------------------- 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h index 0afd7f5d3..5f1a3108e 100644 --- a/Source/cmListFileCache.h +++ b/Source/cmListFileCache.h @@ -111,13 +111,4 @@ struct cmListFile std::vector Functions; }; -struct cmValueWithOrigin { - cmValueWithOrigin(const std::string &value, - const cmListFileBacktrace &bt) - : Value(value), Backtrace(bt) - {} - std::string Value; - cmListFileBacktrace Backtrace; -}; - #endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index abfc40b8c..63c7740e5 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -114,7 +114,8 @@ public: std::vector CompileDefinitionsBacktraces; std::vector SourceEntries; std::vector SourceBacktraces; - std::vector LinkImplementationPropertyEntries; + std::vector LinkImplementationPropertyEntries; + std::vector LinkImplementationPropertyBacktraces; }; //---------------------------------------------------------------------------- @@ -1380,11 +1381,12 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) else if (prop == "LINK_LIBRARIES") { this->Internal->LinkImplementationPropertyEntries.clear(); + this->Internal->LinkImplementationPropertyBacktraces.clear(); if (value) { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmValueWithOrigin entry(value, lfbt); - this->Internal->LinkImplementationPropertyEntries.push_back(entry); + this->Internal->LinkImplementationPropertyEntries.push_back(value); + this->Internal->LinkImplementationPropertyBacktraces.push_back(lfbt); } } else if (prop == "SOURCES") @@ -1482,8 +1484,8 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, if (value && *value) { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmValueWithOrigin entry(value, lfbt); - this->Internal->LinkImplementationPropertyEntries.push_back(entry); + this->Internal->LinkImplementationPropertyEntries.push_back(value); + this->Internal->LinkImplementationPropertyBacktraces.push_back(lfbt); } } else if (prop == "SOURCES") @@ -2048,17 +2050,7 @@ const char *cmTarget::GetProperty(const std::string& prop, } static std::string output; - output = ""; - std::string sep; - for (std::vector::const_iterator - it = this->Internal->LinkImplementationPropertyEntries.begin(), - end = this->Internal->LinkImplementationPropertyEntries.end(); - it != end; ++it) - { - output += sep; - output += it->Value; - sep = ";"; - } + output = cmJoin(this->Internal->LinkImplementationPropertyEntries, ";"); return output.c_str(); } // the type property returns what type the target is @@ -3223,19 +3215,21 @@ void cmTarget::ComputeLinkImplementationLibraries( cmOptionalLinkImplementation& impl, cmTarget const* head) const { + std::vector::const_iterator btIt = + this->Internal->LinkImplementationPropertyBacktraces.begin(); // Collect libraries directly linked in this configuration. - for (std::vector::const_iterator + for (std::vector::const_iterator le = this->Internal->LinkImplementationPropertyEntries.begin(), end = this->Internal->LinkImplementationPropertyEntries.end(); - le != end; ++le) + le != end; ++le, ++btIt) { std::vector llibs; cmGeneratorExpressionDAGChecker dagChecker( this->GetName(), "LINK_LIBRARIES", 0, 0); - cmGeneratorExpression ge(le->Backtrace); + cmGeneratorExpression ge(*btIt); cmsys::auto_ptr const cge = - ge.Parse(le->Value); + ge.Parse(*le); std::string const evaluated = cge->Evaluate(this->Makefile, config, false, head, &dagChecker); cmSystemTools::ExpandListArgument(evaluated, llibs); @@ -3290,7 +3284,7 @@ void cmTarget::ComputeLinkImplementationLibraries( // The entry is meant for this configuration. impl.Libraries.push_back( cmLinkImplItem(name, this->FindTargetToLink(name), - le->Backtrace, evaluated != le->Value)); + *btIt, evaluated != *le)); } std::set const& seenProps = cge->GetSeenTargetProperties();