diff options
author | Brad King <brad.king@kitware.com> | 2014-06-30 14:47:21 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-07-07 12:52:40 (GMT) |
commit | 363cd33ebe5a8fb495fffc07cf39c59082e83bbf (patch) | |
tree | ecd102026f0454ac5c43c5c1f55117c073de6468 /Source/cmTarget.cxx | |
parent | 251e835b3f7320f0099d003de5a675af58e62e46 (diff) | |
download | CMake-363cd33ebe5a8fb495fffc07cf39c59082e83bbf.zip CMake-363cd33ebe5a8fb495fffc07cf39c59082e83bbf.tar.gz CMake-363cd33ebe5a8fb495fffc07cf39c59082e83bbf.tar.bz2 |
cmTarget: Add method to add usage requirements from linked interfaces
Create a cmTargetInternals::AddInterfaceEntries method to construct a
$<TARGET_PROPERTY:tgt,INTERFACE_XYZ> 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 $<TARGET_PROPERTY:tgt,INTERFACE_XYZ>
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.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r-- | Source/cmTarget.cxx | 29 |
1 files changed, 29 insertions, 0 deletions
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<TargetPropertyEntry*> SourceEntries; std::vector<cmValueWithOrigin> LinkImplementationPropertyEntries; + void AddInterfaceEntries( + cmTarget const* thisTarget, std::string const& config, + std::string const& prop, std::vector<TargetPropertyEntry*>& entries); + std::map<std::string, std::vector<TargetPropertyEntry*> > CachedLinkInterfaceIncludeDirectoriesEntries; std::map<std::string, std::vector<TargetPropertyEntry*> > @@ -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<TargetPropertyEntry*>& entries) +{ + if(cmTarget::LinkImplementation const* impl = + thisTarget->GetLinkImplementationLibraries(config)) + { + for (std::vector<cmLinkImplItem>::const_iterator + it = impl->Libraries.begin(), end = impl->Libraries.end(); + it != end; ++it) + { + if(it->Target) + { + std::string genex = + "$<TARGET_PROPERTY:" + *it + "," + prop + ">"; + cmGeneratorExpression ge(&it->Backtrace); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(genex); + entries.push_back( + new cmTargetInternals::TargetPropertyEntry(cge, *it)); + } + } + } +} + +//---------------------------------------------------------------------------- cmTarget::LinkImplementation const* cmTarget::GetLinkImplementation(const std::string& config) const { |