From 363cd33ebe5a8fb495fffc07cf39c59082e83bbf Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 30 Jun 2014 10:47:21 -0400 Subject: cmTarget: Add method to add usage requirements from linked interfaces Create a cmTargetInternals::AddInterfaceEntries method to construct a $ generator expression and evaluate it for every target in the link implementation. This will be useful to de-duplicate such evaluation for each usage requirement separately. The new method will soon be used in the implementation of the INTERFACE_* usage requirement lookup methods (GetSourceFiles, GetCompileOptions, GetCompileDefinitions, GetCompileFeatures, GetIncludeDirectories). It is necessary for these methods to determine whether an expression in LinkImplementationPropertyEntries evaluates to a target or not because generator expression evaluation reports an error for non-targets and we construct a $ expression for each entry that is a target. The implementation of each usage requirement currently processes the LinkImplementationPropertyEntries and evaluates all generator expressions to determine targets. That is no longer necessary because GetLinkImplementationLibraries now returns resolved and cached targets together with their name. Use it to implement AddInterfaceEntries. --- Source/cmTarget.cxx | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 6bc4273..0ad4ffb 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -181,6 +181,10 @@ public: std::vector SourceEntries; std::vector LinkImplementationPropertyEntries; + void AddInterfaceEntries( + cmTarget const* thisTarget, std::string const& config, + std::string const& prop, std::vector& entries); + std::map > CachedLinkInterfaceIncludeDirectoriesEntries; std::map > @@ -6550,6 +6554,31 @@ void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, } //---------------------------------------------------------------------------- +void cmTargetInternals::AddInterfaceEntries( + cmTarget const* thisTarget, std::string const& config, + std::string const& prop, std::vector& entries) +{ + if(cmTarget::LinkImplementation const* impl = + thisTarget->GetLinkImplementationLibraries(config)) + { + for (std::vector::const_iterator + it = impl->Libraries.begin(), end = impl->Libraries.end(); + it != end; ++it) + { + if(it->Target) + { + std::string genex = + "$"; + cmGeneratorExpression ge(&it->Backtrace); + cmsys::auto_ptr cge = ge.Parse(genex); + entries.push_back( + new cmTargetInternals::TargetPropertyEntry(cge, *it)); + } + } + } +} + +//---------------------------------------------------------------------------- cmTarget::LinkImplementation const* cmTarget::GetLinkImplementation(const std::string& config) const { -- cgit v0.12