From bf5ece51c3827dc05018128fefe8270da88cfefb Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 5 Nov 2012 14:48:42 +0100 Subject: Keep track of properties used to determine linker libraries. Those properties can't later be implicitly defined by the interface of those link libraries. --- Source/cmGeneratorExpression.cxx | 10 +++++++- Source/cmGeneratorExpression.h | 4 +++ Source/cmGeneratorExpressionEvaluator.cxx | 8 ++++++ Source/cmGeneratorExpressionEvaluator.h | 1 + Source/cmTarget.cxx | 42 ++++++++++++++++++++++++++++++- Source/cmTarget.h | 10 ++++++++ 6 files changed, 73 insertions(+), 2 deletions(-) diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 6d003e1..4063697 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -94,7 +94,15 @@ const char *cmCompiledGeneratorExpression::Evaluate( for ( ; it != end; ++it) { - this->Output += (*it)->Evaluate(&context, dagChecker); + const std::string result = (*it)->Evaluate(&context, dagChecker); + this->Output += result; + + for(std::set::const_iterator + p = context.SeenTargetProperties.begin(); + p != context.SeenTargetProperties.end(); ++p) + { + this->SeenTargetProperties[*p] += result + ";"; + } if (context.HadError) { this->Output = ""; diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index dcdfefb..b58dde5 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -83,6 +83,9 @@ public: std::set const& GetTargets() const { return this->Targets; } + std::map const& GetSeenTargetProperties() const + { return this->SeenTargetProperties; } + ~cmCompiledGeneratorExpression(); std::string GetInput() const @@ -110,6 +113,7 @@ private: bool NeedsParsing; mutable std::set Targets; + mutable std::map SeenTargetProperties; mutable std::string Output; }; diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 82becaf..f4e4131 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -380,6 +380,14 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } } + if (target == context->HeadTarget) + { + // Keep track of the properties seen while processing. + // The evaluation of the LINK_LIBRARIES generator expressions + // will check this to ensure that properties form a DAG. + context->SeenTargetProperties.insert(propertyName); + } + if (propertyName.empty()) { reportError(context, content->GetOriginalExpression(), diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h index 59804ff..fb6c7ee 100644 --- a/Source/cmGeneratorExpressionEvaluator.h +++ b/Source/cmGeneratorExpressionEvaluator.h @@ -24,6 +24,7 @@ struct cmGeneratorExpressionContext { cmListFileBacktrace Backtrace; std::set Targets; + std::set SeenTargetProperties; cmMakefile *Makefile; const char *Config; cmTarget *HeadTarget; // The target whose property is being evaluated. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 25054c5..e4adb09 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2164,16 +2164,19 @@ void cmTarget::GetDirectLinkLibraries(const char *config, { cmListFileBacktrace lfbt; cmGeneratorExpression ge(lfbt); + const cmsys::auto_ptr cge = ge.Parse(prop); cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(), "LINK_LIBRARIES", 0, 0); - cmSystemTools::ExpandListArgument(ge.Parse(prop)->Evaluate(this->Makefile, + cmSystemTools::ExpandListArgument(cge->Evaluate(this->Makefile, config, false, head, &dagChecker), libs); + + this->AddLinkDependentTargetsForProperties(cge->GetSeenTargetProperties()); } } @@ -4377,6 +4380,43 @@ const char* cmTarget::GetExportMacro() } //---------------------------------------------------------------------------- +void cmTarget::GetLinkDependentTargetsForProperty(const std::string &p, + std::set &targets) +{ + const std::map >::const_iterator findIt + = this->LinkDependentProperties.find(p); + if (findIt != this->LinkDependentProperties.end()) + { + targets = findIt->second; + } +} + +//---------------------------------------------------------------------------- +bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) +{ + return this->LinkImplicitNullProperties.find(p) + != this->LinkImplicitNullProperties.end(); +} + +//---------------------------------------------------------------------------- +void cmTarget::AddLinkDependentTargetsForProperties( + const std::map &map) +{ + for (std::map::const_iterator it = map.begin(); + it != map.end(); ++it) + { + std::vector targets; + cmSystemTools::ExpandListArgument(it->second.c_str(), targets); + this->LinkDependentProperties[it->first].insert(targets.begin(), + targets.end()); + if (!this->GetProperty(it->first.c_str())) + { + this->LinkImplicitNullProperties.insert(it->first); + } + } +} + +//---------------------------------------------------------------------------- void cmTarget::GetLanguages(std::set& languages) const { for(std::vector::const_iterator diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d4069fa..5ce7d53 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -487,6 +487,13 @@ public: std::vector GetIncludeDirectories(const char *config); void InsertInclude(const cmMakefileIncludeDirectoriesEntry &entry, bool before = false); + + void GetLinkDependentTargetsForProperty(const std::string &p, + std::set &targets); + bool IsNullImpliedByLinkLibraries(const std::string &p); + + void AddLinkDependentTargetsForProperties( + const std::map &map); private: /** * A list of direct dependencies. Use in conjunction with DependencyMap. @@ -596,6 +603,9 @@ private: bool DLLPlatform; bool IsApple; bool IsImportedTarget; + mutable std::map > + LinkDependentProperties; + mutable std::set LinkImplicitNullProperties; // Cache target output paths for each configuration. struct OutputInfo; -- cgit v0.12