cmTarget: Simplify INTERFACE_INCLUDE_DIRECTORIES usage requirement lookup

Use the AddInterfaceEntries helper to avoid duplication.  In
TargetPropertyEntry, replace the TargetName string member with a
reference to the full cmLinkImplItem that produced the entry.  This is
possible because the cmLinkImplItem is available in AddInterfaceEntries
(it was not available in GetIncludeDirectories).  Having the full
cmLinkImplItem allows processIncludeDirectories to implement CMP0027 OLD
behavior without repeating the target name lookup.

Update the RunCMake.CompatibleInterface test DebugProperties case
expected output for the new order of the messages.
This commit is contained in:
Brad King 2014-06-30 13:23:49 -04:00
parent b5b098ebb3
commit 93790506f5
2 changed files with 22 additions and 68 deletions

View File

@ -165,14 +165,16 @@ public:
std::set<cmLinkItem> UtilityItems; std::set<cmLinkItem> UtilityItems;
bool UtilityItemsDone; bool UtilityItemsDone;
struct TargetPropertyEntry { class TargetPropertyEntry {
static cmLinkImplItem NoLinkImplItem;
public:
TargetPropertyEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge, TargetPropertyEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge,
const std::string &targetName = std::string()) cmLinkImplItem const& item = NoLinkImplItem)
: ge(cge), TargetName(targetName) : ge(cge), LinkImplItem(item)
{} {}
const cmsys::auto_ptr<cmCompiledGeneratorExpression> ge; const cmsys::auto_ptr<cmCompiledGeneratorExpression> ge;
std::vector<std::string> CachedEntries; std::vector<std::string> CachedEntries;
const std::string TargetName; cmLinkImplItem const& LinkImplItem;
}; };
std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries; std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries;
std::vector<TargetPropertyEntry*> CompileOptionsEntries; std::vector<TargetPropertyEntry*> CompileOptionsEntries;
@ -206,6 +208,8 @@ public:
std::map<std::string, bool> CacheLinkImplementationClosureDone; std::map<std::string, bool> CacheLinkImplementationClosureDone;
}; };
cmLinkImplItem cmTargetInternals::TargetPropertyEntry::NoLinkImplItem;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void deleteAndClear( void deleteAndClear(
std::vector<cmTargetInternals::TargetPropertyEntry*> &entries) std::vector<cmTargetInternals::TargetPropertyEntry*> &entries)
@ -2012,24 +2016,10 @@ static void processIncludeDirectories(cmTarget const* tgt,
for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator
it = entries.begin(), end = entries.end(); it != end; ++it) it = entries.begin(), end = entries.end(); it != end; ++it)
{ {
std::string targetName = (*it)->TargetName; cmLinkImplItem const& item = (*it)->LinkImplItem;
bool checkCMP0027 = false; std::string const& targetName = item;
if(!cmGeneratorExpression::IsValidTargetName(targetName) bool const fromImported = item.Target && item.Target->IsImported();
&& cmGeneratorExpression::Find(targetName) != std::string::npos) bool const checkCMP0027 = item.FromGenex;
{
std::string evaluatedTargetName;
cmGeneratorExpression ge;
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(targetName);
evaluatedTargetName = cge->Evaluate(mf, config, false, tgt, 0, 0);
checkCMP0027 = evaluatedTargetName != targetName;
targetName = evaluatedTargetName;
}
cmTarget *dependentTarget = mf->FindTargetToUse(targetName);
const bool fromImported =
dependentTarget && dependentTarget->IsImported();
bool testIsOff = true; bool testIsOff = true;
bool cacheIncludes = false; bool cacheIncludes = false;
std::vector<std::string>& entryIncludes = (*it)->CachedEntries; std::vector<std::string>& entryIncludes = (*it)->CachedEntries;
@ -2200,45 +2190,9 @@ cmTarget::GetIncludeDirectories(const std::string& config) const
if (!this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[config]) if (!this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[config])
{ {
for (std::vector<cmValueWithOrigin>::const_iterator this->Internal->AddInterfaceEntries(
it = this->Internal->LinkImplementationPropertyEntries.begin(), this, config, "INTERFACE_INCLUDE_DIRECTORIES",
end = this->Internal->LinkImplementationPropertyEntries.end(); this->Internal->CachedLinkInterfaceIncludeDirectoriesEntries[config]);
it != end; ++it)
{
if (!cmGeneratorExpression::IsValidTargetName(it->Value)
&& cmGeneratorExpression::Find(it->Value) == std::string::npos)
{
continue;
}
{
cmGeneratorExpression ge;
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(it->Value);
std::string result = cge->Evaluate(this->Makefile, config,
false, this, 0, 0);
if (!this->Makefile->FindTargetToUse(result))
{
continue;
}
}
std::string includeGenex = "$<TARGET_PROPERTY:" +
it->Value + ",INTERFACE_INCLUDE_DIRECTORIES>";
if (cmGeneratorExpression::Find(it->Value) != std::string::npos)
{
// Because it->Value is a generator expression, ensure that it
// evaluates to the non-empty string before being used in the
// TARGET_PROPERTY expression.
includeGenex = "$<$<BOOL:" + it->Value + ">:" + includeGenex + ">";
}
cmGeneratorExpression ge(&it->Backtrace);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(
includeGenex);
this->Internal
->CachedLinkInterfaceIncludeDirectoriesEntries[config].push_back(
new cmTargetInternals::TargetPropertyEntry(cge,
it->Value));
}
if(this->Makefile->IsOn("APPLE")) if(this->Makefile->IsOn("APPLE"))
{ {

View File

@ -1,10 +1,3 @@
CMake Debug Log:
Boolean compatibility of property "BOOL_PROP7" for target
"CompatibleInterface" \(result: "FALSE"\):
\* Target "CompatibleInterface" property is implied by use.
\* Target "iface1" property value "FALSE" \(Agree\)
+
CMake Debug Log: CMake Debug Log:
Boolean compatibility of property "BOOL_PROP1" for target Boolean compatibility of property "BOOL_PROP1" for target
"CompatibleInterface" \(result: "TRUE"\): "CompatibleInterface" \(result: "TRUE"\):
@ -46,6 +39,13 @@ CMake Debug Log:
\* Target "iface1" property value "FALSE" \(Interface set\) \* Target "iface1" property value "FALSE" \(Interface set\)
\* Target "iface2" property value "FALSE" \(Agree\) \* Target "iface2" property value "FALSE" \(Agree\)
+ +
CMake Debug Log:
Boolean compatibility of property "BOOL_PROP7" for target
"CompatibleInterface" \(result: "FALSE"\):
\* Target "CompatibleInterface" property is implied by use.
\* Target "iface1" property value "FALSE" \(Agree\)
+
CMake Debug Log: CMake Debug Log:
String compatibility of property "STRING_PROP1" for target String compatibility of property "STRING_PROP1" for target
"CompatibleInterface" \(result: "prop1"\): "CompatibleInterface" \(result: "prop1"\):