summaryrefslogtreecommitdiffstats
path: root/Source/cmTarget.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-12-09 15:33:30 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2013-12-09 15:33:30 (GMT)
commit5026696fcc79e1ec4b1f40069566614852b4c312 (patch)
tree59e4aa07dfce266464f71eca241c04e17a3e578d /Source/cmTarget.cxx
parent1ab140ef8f4be77503f59f25d6e2a036d0f44ca2 (diff)
parent77f3772784152701ff0eee5e4a19177996c03c0e (diff)
downloadCMake-5026696fcc79e1ec4b1f40069566614852b4c312.zip
CMake-5026696fcc79e1ec4b1f40069566614852b4c312.tar.gz
CMake-5026696fcc79e1ec4b1f40069566614852b4c312.tar.bz2
Merge topic 'INTERFACE_AUTOUIC_OPTIONS'
77f3772 cmTarget: Require a compatible INTERFACE_AUTOUIC_OPTIONS from dependencies. 2e60b5f cmTarget: Report origin of COMPATIBLE_INTERFACE properties.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r--Source/cmTarget.cxx292
1 files changed, 153 insertions, 139 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 8e4ce8b..38fe945 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -135,7 +135,6 @@ public:
};
std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries;
std::vector<TargetPropertyEntry*> CompileOptionsEntries;
- std::vector<TargetPropertyEntry*> AutoUicOptionsEntries;
std::vector<TargetPropertyEntry*> CompileDefinitionsEntries;
std::vector<cmValueWithOrigin> LinkInterfacePropertyEntries;
@@ -144,14 +143,11 @@ public:
mutable std::map<std::string, std::vector<TargetPropertyEntry*> >
CachedLinkInterfaceCompileOptionsEntries;
mutable std::map<std::string, std::vector<TargetPropertyEntry*> >
- CachedLinkInterfaceAutoUicOptionsEntries;
- mutable std::map<std::string, std::vector<TargetPropertyEntry*> >
CachedLinkInterfaceCompileDefinitionsEntries;
mutable std::map<std::string, bool> CacheLinkInterfaceIncludeDirectoriesDone;
mutable std::map<std::string, bool> CacheLinkInterfaceCompileDefinitionsDone;
mutable std::map<std::string, bool> CacheLinkInterfaceCompileOptionsDone;
- mutable std::map<std::string, bool> CacheLinkInterfaceAutoUicOptionsDone;
};
//----------------------------------------------------------------------------
@@ -186,7 +182,6 @@ cmTargetInternals::~cmTargetInternals()
{
deleteAndClear(this->CachedLinkInterfaceIncludeDirectoriesEntries);
deleteAndClear(this->CachedLinkInterfaceCompileOptionsEntries);
- deleteAndClear(this->CachedLinkInterfaceAutoUicOptionsEntries);
deleteAndClear(this->CachedLinkInterfaceCompileDefinitionsEntries);
}
@@ -1478,17 +1473,6 @@ void cmTarget::SetProperty(const char* prop, const char* value)
new cmTargetInternals::TargetPropertyEntry(cge));
return;
}
- if(strcmp(prop,"AUTOUIC_OPTIONS") == 0)
- {
- cmListFileBacktrace lfbt;
- this->Makefile->GetBacktrace(lfbt);
- cmGeneratorExpression ge(lfbt);
- deleteAndClear(this->Internal->AutoUicOptionsEntries);
- cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
- this->Internal->AutoUicOptionsEntries.push_back(
- new cmTargetInternals::TargetPropertyEntry(cge));
- return;
- }
if(strcmp(prop,"COMPILE_DEFINITIONS") == 0)
{
cmListFileBacktrace lfbt;
@@ -1563,15 +1547,6 @@ void cmTarget::AppendProperty(const char* prop, const char* value,
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
return;
}
- if(strcmp(prop,"AUTOUIC_OPTIONS") == 0)
- {
- cmListFileBacktrace lfbt;
- this->Makefile->GetBacktrace(lfbt);
- cmGeneratorExpression ge(lfbt);
- this->Internal->AutoUicOptionsEntries.push_back(
- new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
- return;
- }
if(strcmp(prop,"COMPILE_DEFINITIONS") == 0)
{
cmListFileBacktrace lfbt;
@@ -2071,100 +2046,26 @@ static void processCompileOptions(cmTarget const* tgt,
void cmTarget::GetAutoUicOptions(std::vector<std::string> &result,
const char *config) const
{
- std::set<std::string> uniqueOptions;
- cmListFileBacktrace lfbt;
-
- cmGeneratorExpressionDAGChecker dagChecker(lfbt,
- this->GetName(),
- "AUTOUIC_OPTIONS", 0, 0);
-
- std::vector<std::string> debugProperties;
- const char *debugProp =
- this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
- if (debugProp)
- {
- cmSystemTools::ExpandListArgument(debugProp, debugProperties);
- }
-
- bool debugOptions = !this->DebugCompileOptionsDone
- && std::find(debugProperties.begin(),
- debugProperties.end(),
- "AUTOUIC_OPTIONS")
- != debugProperties.end();
-
- if (this->Makefile->IsGeneratingBuildSystem())
- {
- this->DebugAutoUicOptionsDone = true;
- }
-
- processCompileOptions(this,
- this->Internal->AutoUicOptionsEntries,
- result,
- uniqueOptions,
- &dagChecker,
- config,
- debugOptions);
-
- std::string configString = config ? config : "";
- if (!this->Internal->CacheLinkInterfaceAutoUicOptionsDone[configString])
+ const char *prop
+ = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS",
+ config);
+ if (!prop)
{
- for (std::vector<cmValueWithOrigin>::const_iterator
- it = this->Internal->LinkInterfacePropertyEntries.begin(),
- end = this->Internal->LinkInterfacePropertyEntries.end();
- it != end; ++it)
- {
- if (!cmGeneratorExpression::IsValidTargetName(it->Value)
- && cmGeneratorExpression::Find(it->Value) == std::string::npos)
- {
- continue;
- }
- {
- cmGeneratorExpression ge(lfbt);
- cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
- ge.Parse(it->Value);
- std::string targetResult = cge->Evaluate(this->Makefile, config,
- false, this, 0, 0);
- if (!this->Makefile->FindTargetToUse(targetResult.c_str()))
- {
- continue;
- }
- }
- std::string optionGenex = "$<TARGET_PROPERTY:" +
- it->Value + ",INTERFACE_AUTOUIC_OPTIONS>";
- 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.
- optionGenex = "$<$<BOOL:" + it->Value + ">:" + optionGenex + ">";
- }
- cmGeneratorExpression ge(it->Backtrace);
- cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(
- optionGenex);
-
- this->Internal
- ->CachedLinkInterfaceAutoUicOptionsEntries[configString].push_back(
- new cmTargetInternals::TargetPropertyEntry(cge,
- it->Value));
- }
+ return;
}
+ cmListFileBacktrace lfbt;
+ cmGeneratorExpression ge(lfbt);
- processCompileOptions(this,
- this->Internal->CachedLinkInterfaceAutoUicOptionsEntries[configString],
- result,
- uniqueOptions,
- &dagChecker,
- config,
- debugOptions);
-
- if (!this->Makefile->IsGeneratingBuildSystem())
- {
- deleteAndClear(this->Internal->CachedLinkInterfaceAutoUicOptionsEntries);
- }
- else
- {
- this->Internal->CacheLinkInterfaceAutoUicOptionsDone[configString] = true;
- }
+ cmGeneratorExpressionDAGChecker dagChecker(lfbt,
+ this->GetName(),
+ "AUTOUIC_OPTIONS", 0, 0);
+ cmSystemTools::ExpandListArgument(ge.Parse(prop)
+ ->Evaluate(this->Makefile,
+ config,
+ false,
+ this,
+ &dagChecker),
+ result);
}
//----------------------------------------------------------------------------
@@ -2874,24 +2775,6 @@ const char *cmTarget::GetProperty(const char* prop,
}
return output.c_str();
}
- if(strcmp(prop,"AUTOUIC_OPTIONS") == 0)
- {
- static std::string output;
- output = "";
- std::string sep;
- typedef cmTargetInternals::TargetPropertyEntry
- TargetPropertyEntry;
- for (std::vector<TargetPropertyEntry*>::const_iterator
- it = this->Internal->AutoUicOptionsEntries.begin(),
- end = this->Internal->AutoUicOptionsEntries.end();
- it != end; ++it)
- {
- output += sep;
- output += (*it)->ge->GetInput();
- sep = ";";
- }
- return output.c_str();
- }
if(strcmp(prop,"COMPILE_DEFINITIONS") == 0)
{
static std::string output;
@@ -4423,6 +4306,95 @@ const char* impliedValue<const char*>(const char*)
return "";
}
+
+template<typename PropertyType>
+std::string valueAsString(PropertyType);
+template<>
+std::string valueAsString<bool>(bool value)
+{
+ return value ? "TRUE" : "FALSE";
+}
+template<>
+std::string valueAsString<const char*>(const char* value)
+{
+ return value ? value : "(unset)";
+}
+
+//----------------------------------------------------------------------------
+void
+cmTarget::ReportPropertyOrigin(const std::string &p,
+ const std::string &result,
+ const std::string &report,
+ const std::string &compatibilityType) const
+{
+ std::vector<std::string> debugProperties;
+ const char *debugProp =
+ this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
+ if (debugProp)
+ {
+ cmSystemTools::ExpandListArgument(debugProp, debugProperties);
+ }
+
+ bool debugOrigin = !this->DebugCompatiblePropertiesDone[p]
+ && std::find(debugProperties.begin(),
+ debugProperties.end(),
+ p)
+ != debugProperties.end();
+
+ if (this->Makefile->IsGeneratingBuildSystem())
+ {
+ this->DebugCompatiblePropertiesDone[p] = true;
+ }
+ if (!debugOrigin)
+ {
+ return;
+ }
+
+ std::string areport = compatibilityType;
+ areport += std::string(" of property \"") + p + "\" for target \"";
+ areport += std::string(this->GetName());
+ areport += "\" (result: \"";
+ areport += result;
+ areport += "\"):\n" + report;
+
+ cmListFileBacktrace lfbt;
+ this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport, lfbt);
+}
+
+//----------------------------------------------------------------------------
+std::string compatibilityType(CompatibleType t)
+{
+ switch(t)
+ {
+ case BoolType:
+ return "Boolean compatibility";
+ case StringType:
+ return "String compatibility";
+ case NumberMaxType:
+ return "Numeric maximum compatibility";
+ case NumberMinType:
+ return "Numeric minimum compatibility";
+ }
+ assert(!"Unreachable!");
+ return "";
+}
+
+//----------------------------------------------------------------------------
+std::string compatibilityAgree(CompatibleType t, bool dominant)
+{
+ switch(t)
+ {
+ case BoolType:
+ case StringType:
+ return dominant ? "(Disagree)\n" : "(Agree)\n";
+ case NumberMaxType:
+ case NumberMinType:
+ return dominant ? "(Dominant)\n" : "(Ignored)\n";
+ }
+ assert(!"Unreachable!");
+ return "";
+}
+
//----------------------------------------------------------------------------
template<typename PropertyType>
PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
@@ -4450,6 +4422,23 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
const cmComputeLinkInformation::ItemVector &deps = info->GetItems();
bool propInitialized = explicitlySet;
+ std::string report = " * Target \"";
+ report += tgt->GetName();
+ if (explicitlySet)
+ {
+ report += "\" has property content \"";
+ report += valueAsString<PropertyType>(propContent);
+ report += "\"\n";
+ }
+ else if (impliedByUse)
+ {
+ report += "\" property is implied by use.\n";
+ }
+ else
+ {
+ report += "\" property not set.\n";
+ }
+
for(cmComputeLinkInformation::ItemVector::const_iterator li =
deps.begin();
li != deps.end(); ++li)
@@ -4471,12 +4460,25 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
PropertyType ifacePropContent =
getTypedProperty<PropertyType>(li->Target,
("INTERFACE_" + p).c_str(), 0);
+
+ std::string reportEntry;
+ if (ifacePropContent)
+ {
+ reportEntry += " * Target \"";
+ reportEntry += li->Target->GetName();
+ reportEntry += "\" property value \"";
+ reportEntry += valueAsString<PropertyType>(ifacePropContent);
+ reportEntry += "\" ";
+ }
+
if (explicitlySet)
{
if (ifaceIsSet)
{
PropertyType consistent = consistentProperty(propContent,
ifacePropContent, t);
+ report += reportEntry;
+ report += compatibilityAgree(t, propContent != consistent);
if (!consistent)
{
cmOStringStream e;
@@ -4489,7 +4491,6 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
}
else
{
- // Agree
propContent = consistent;
continue;
}
@@ -4503,10 +4504,19 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
else if (impliedByUse)
{
propContent = impliedValue<PropertyType>(propContent);
+
+ reportEntry += " * Target \"";
+ reportEntry += li->Target->GetName();
+ reportEntry += "\" property value \"";
+ reportEntry += valueAsString<PropertyType>(propContent);
+ reportEntry += "\" ";
+
if (ifaceIsSet)
{
PropertyType consistent = consistentProperty(propContent,
ifacePropContent, t);
+ report += reportEntry;
+ report += compatibilityAgree(t, propContent != consistent);
if (!consistent)
{
cmOStringStream e;
@@ -4520,7 +4530,6 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
}
else
{
- // Agree
propContent = consistent;
continue;
}
@@ -4539,6 +4548,8 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
{
PropertyType consistent = consistentProperty(propContent,
ifacePropContent, t);
+ report += reportEntry;
+ report += compatibilityAgree(t, propContent != consistent);
if (!consistent)
{
cmOStringStream e;
@@ -4551,13 +4562,13 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
}
else
{
- // Agree.
propContent = consistent;
continue;
}
}
else
{
+ report += reportEntry + "(Interface set)\n";
propContent = ifacePropContent;
propInitialized = true;
}
@@ -4569,6 +4580,9 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
}
}
}
+
+ tgt->ReportPropertyOrigin(p, valueAsString<PropertyType>(propContent),
+ report, compatibilityType(t));
return propContent;
}
@@ -4682,7 +4696,8 @@ bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p,
{
return false;
}
- return isLinkDependentProperty(this, p, "COMPATIBLE_INTERFACE_STRING",
+ return (p == "AUTOUIC_OPTIONS") ||
+ isLinkDependentProperty(this, p, "COMPATIBLE_INTERFACE_STRING",
config);
}
@@ -6101,7 +6116,6 @@ cmTargetInternalPointer::~cmTargetInternalPointer()
{
deleteAndClear(this->Pointer->IncludeDirectoriesEntries);
deleteAndClear(this->Pointer->CompileOptionsEntries);
- deleteAndClear(this->Pointer->AutoUicOptionsEntries);
deleteAndClear(this->Pointer->CompileDefinitionsEntries);
delete this->Pointer;
}