summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-10-22 17:23:06 (GMT)
committerStephen Kelly <steveire@gmail.com>2013-10-24 06:42:04 (GMT)
commite4e20c1d194152a97043e94f1bd5ef9476812682 (patch)
treeea80921801116b7dbac41c40f8540bc7ac69df26 /Source
parent98777694b99868bdad2ab6eb7e3d6b5113bfa204 (diff)
downloadCMake-e4e20c1d194152a97043e94f1bd5ef9476812682.zip
CMake-e4e20c1d194152a97043e94f1bd5ef9476812682.tar.gz
CMake-e4e20c1d194152a97043e94f1bd5ef9476812682.tar.bz2
cmTarget: Add enumeration for consistency to expect from properties.
The type of consistency to be expected will be extended to cover numeric minimum and maximum.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmTarget.cxx75
1 files changed, 57 insertions, 18 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index b086f16..91a7be8 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -4450,20 +4450,34 @@ const char *getTypedProperty<const char *>(cmTarget *tgt, const char *prop,
return tgt->GetProperty(prop);
}
+enum CompatibleType
+{
+ BoolType,
+ StringType
+};
+
//----------------------------------------------------------------------------
template<typename PropertyType>
-PropertyType consistentProperty(PropertyType lhs, PropertyType rhs);
+PropertyType consistentProperty(PropertyType lhs, PropertyType rhs,
+ CompatibleType t);
//----------------------------------------------------------------------------
template<>
-bool consistentProperty(bool lhs, bool rhs)
+bool consistentProperty(bool lhs, bool rhs, CompatibleType)
{
return lhs == rhs;
}
//----------------------------------------------------------------------------
+const char * consistentStringProperty(const char *lhs, const char *rhs)
+{
+ return strcmp(lhs, rhs) == 0 ? lhs : 0;
+}
+
+//----------------------------------------------------------------------------
template<>
-const char* consistentProperty(const char *lhs, const char *rhs)
+const char* consistentProperty(const char *lhs, const char *rhs,
+ CompatibleType t)
{
if (!lhs && !rhs)
{
@@ -4477,7 +4491,16 @@ const char* consistentProperty(const char *lhs, const char *rhs)
{
return lhs ? lhs : "";
}
- return strcmp(lhs, rhs) == 0 ? lhs : 0;
+ switch(t)
+ {
+ case BoolType:
+ assert(!"consistentProperty for strings called with BoolType");
+ return 0;
+ case StringType:
+ return consistentStringProperty(lhs, rhs);
+ }
+ assert(!"Unreachable!");
+ return 0;
}
template<typename PropertyType>
@@ -4499,6 +4522,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt,
const std::string &p,
const char *config,
const char *defaultValue,
+ CompatibleType t,
PropertyType *)
{
PropertyType propContent = getTypedProperty<PropertyType>(tgt, p.c_str(),
@@ -4545,7 +4569,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt,
if (ifaceIsSet)
{
PropertyType consistent = consistentProperty(propContent,
- ifacePropContent);
+ ifacePropContent, t);
if (!consistent)
{
cmOStringStream e;
@@ -4575,7 +4599,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt,
if (ifaceIsSet)
{
PropertyType consistent = consistentProperty(propContent,
- ifacePropContent);
+ ifacePropContent, t);
if (!consistent)
{
cmOStringStream e;
@@ -4607,7 +4631,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt,
if (propInitialized)
{
PropertyType consistent = consistentProperty(propContent,
- ifacePropContent);
+ ifacePropContent, t);
if (!consistent)
{
cmOStringStream e;
@@ -4646,7 +4670,7 @@ bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p,
const char *config)
{
return checkInterfacePropertyCompatibility<bool>(this, p, config, "FALSE",
- 0);
+ BoolType, 0);
}
//----------------------------------------------------------------------------
@@ -4657,7 +4681,8 @@ const char * cmTarget::GetLinkInterfaceDependentStringProperty(
return checkInterfacePropertyCompatibility<const char *>(this,
p,
config,
- "empty", 0);
+ "empty",
+ StringType, 0);
}
//----------------------------------------------------------------------------
@@ -5708,23 +5733,35 @@ template<typename PropertyType>
PropertyType getLinkInterfaceDependentProperty(cmTarget *tgt,
const std::string prop,
const char *config,
+ CompatibleType,
PropertyType *);
template<>
bool getLinkInterfaceDependentProperty(cmTarget *tgt,
- const std::string prop,
- const char *config, bool *)
+ const std::string prop,
+ const char *config,
+ CompatibleType, bool *)
{
return tgt->GetLinkInterfaceDependentBoolProperty(prop, config);
}
template<>
const char * getLinkInterfaceDependentProperty(cmTarget *tgt,
- const std::string prop,
- const char *config,
- const char **)
+ const std::string prop,
+ const char *config,
+ CompatibleType t,
+ const char **)
{
- return tgt->GetLinkInterfaceDependentStringProperty(prop, config);
+ switch(t)
+ {
+ case BoolType:
+ assert(!"String compatibility check function called for boolean");
+ return 0;
+ case StringType:
+ return tgt->GetLinkInterfaceDependentStringProperty(prop, config);
+ }
+ assert(!"Unreachable!");
+ return 0;
}
//----------------------------------------------------------------------------
@@ -5733,6 +5770,7 @@ void checkPropertyConsistency(cmTarget *depender, cmTarget *dependee,
const char *propName,
std::set<cmStdString> &emitted,
const char *config,
+ CompatibleType t,
PropertyType *)
{
const char *prop = dependee->GetProperty(propName);
@@ -5765,7 +5803,7 @@ void checkPropertyConsistency(cmTarget *depender, cmTarget *dependee,
if(emitted.insert(*pi).second)
{
getLinkInterfaceDependentProperty<PropertyType>(depender, *pi, config,
- 0);
+ t, 0);
if (cmSystemTools::GetErrorOccuredFlag())
{
return;
@@ -5794,14 +5832,15 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info,
checkPropertyConsistency<bool>(this, li->Target,
"COMPATIBLE_INTERFACE_BOOL",
- emittedBools, config, 0);
+ emittedBools, config, BoolType, 0);
if (cmSystemTools::GetErrorOccuredFlag())
{
return;
}
checkPropertyConsistency<const char *>(this, li->Target,
"COMPATIBLE_INTERFACE_STRING",
- emittedStrings, config, 0);
+ emittedStrings, config,
+ StringType, 0);
if (cmSystemTools::GetErrorOccuredFlag())
{
return;