summaryrefslogtreecommitdiffstats
path: root/Source/cmTarget.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r--Source/cmTarget.cxx91
1 files changed, 61 insertions, 30 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 71e4737..e7eef78 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -4259,20 +4259,23 @@ enum CompatibleType
//----------------------------------------------------------------------------
template<typename PropertyType>
-PropertyType consistentProperty(PropertyType lhs, PropertyType rhs,
- CompatibleType t);
+std::pair<bool, PropertyType> consistentProperty(PropertyType lhs,
+ PropertyType rhs,
+ CompatibleType t);
//----------------------------------------------------------------------------
template<>
-bool consistentProperty(bool lhs, bool rhs, CompatibleType)
+std::pair<bool, bool> consistentProperty(bool lhs, bool rhs, CompatibleType)
{
- return lhs == rhs;
+ return std::make_pair(lhs == rhs, lhs);
}
//----------------------------------------------------------------------------
-const char * consistentStringProperty(const char *lhs, const char *rhs)
+std::pair<bool, const char*> consistentStringProperty(const char *lhs,
+ const char *rhs)
{
- return strcmp(lhs, rhs) == 0 ? lhs : 0;
+ const bool b = strcmp(lhs, rhs) == 0;
+ return std::make_pair(b, b ? lhs : 0);
}
#if defined(_MSC_VER) && _MSC_VER <= 1200
@@ -4286,49 +4289,69 @@ cmMinimum(const T& l, const T& r) {return l < r ? l : r;}
#endif
//----------------------------------------------------------------------------
-const char * consistentNumberProperty(const char *lhs, const char *rhs,
- CompatibleType t)
+std::pair<bool, const char*> consistentNumberProperty(const char *lhs,
+ const char *rhs,
+ CompatibleType t)
{
+
+#if defined(_MSC_VER)
+ static const char* const null_ptr = 0;
+#else
+# define null_ptr 0
+#endif
+
double lnum;
double rnum;
if(sscanf(lhs, "%lg", &lnum) != 1 ||
sscanf(rhs, "%lg", &rnum) != 1)
{
- return 0;
+ return std::pair<bool, const char*>(false, null_ptr);
}
+#if !defined(_MSC_VER)
+#undef null_ptr
+#endif
+
if (t == NumberMaxType)
{
- return cmMaximum(lnum, rnum) == lnum ? lhs : rhs;
+ return std::make_pair(true, cmMaximum(lnum, rnum) == lnum ? lhs : rhs);
}
else
{
- return cmMinimum(lnum, rnum) == lnum ? lhs : rhs;
+ return std::make_pair(true, cmMinimum(lnum, rnum) == lnum ? lhs : rhs);
}
}
//----------------------------------------------------------------------------
template<>
-const char* consistentProperty(const char *lhs, const char *rhs,
- CompatibleType t)
+std::pair<bool, const char*> consistentProperty(const char *lhs,
+ const char *rhs,
+ CompatibleType t)
{
if (!lhs && !rhs)
{
- return "";
+ return std::make_pair(true, lhs);
}
if (!lhs)
{
- return rhs ? rhs : "";
+ return std::make_pair(true, rhs);
}
if (!rhs)
{
- return lhs ? lhs : "";
+ return std::make_pair(true, lhs);
}
+
+#if defined(_MSC_VER)
+ static const char* const null_ptr = 0;
+#else
+# define null_ptr 0
+#endif
+
switch(t)
{
case BoolType:
assert(!"consistentProperty for strings called with BoolType");
- return 0;
+ return std::pair<bool, const char*>(false, null_ptr);
case StringType:
return consistentStringProperty(lhs, rhs);
case NumberMinType:
@@ -4336,7 +4359,12 @@ const char* consistentProperty(const char *lhs, const char *rhs,
return consistentNumberProperty(lhs, rhs, t);
}
assert(!"Unreachable!");
- return 0;
+ return std::pair<bool, const char*>(false, null_ptr);
+
+#if !defined(_MSC_VER)
+#undef null_ptr
+#endif
+
}
template<typename PropertyType>
@@ -4521,11 +4549,12 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
{
if (ifaceIsSet)
{
- PropertyType consistent = consistentProperty(propContent,
+ std::pair<bool, PropertyType> consistent =
+ consistentProperty(propContent,
ifacePropContent, t);
report += reportEntry;
- report += compatibilityAgree(t, propContent != consistent);
- if (!consistent)
+ report += compatibilityAgree(t, propContent != consistent.second);
+ if (!consistent.first)
{
cmOStringStream e;
e << "Property " << p << " on target \""
@@ -4537,7 +4566,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
}
else
{
- propContent = consistent;
+ propContent = consistent.second;
continue;
}
}
@@ -4559,11 +4588,12 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
if (ifaceIsSet)
{
- PropertyType consistent = consistentProperty(propContent,
+ std::pair<bool, PropertyType> consistent =
+ consistentProperty(propContent,
ifacePropContent, t);
report += reportEntry;
- report += compatibilityAgree(t, propContent != consistent);
- if (!consistent)
+ report += compatibilityAgree(t, propContent != consistent.second);
+ if (!consistent.first)
{
cmOStringStream e;
e << "Property " << p << " on target \""
@@ -4576,7 +4606,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
}
else
{
- propContent = consistent;
+ propContent = consistent.second;
continue;
}
}
@@ -4592,11 +4622,12 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
{
if (propInitialized)
{
- PropertyType consistent = consistentProperty(propContent,
+ std::pair<bool, PropertyType> consistent =
+ consistentProperty(propContent,
ifacePropContent, t);
report += reportEntry;
- report += compatibilityAgree(t, propContent != consistent);
- if (!consistent)
+ report += compatibilityAgree(t, propContent != consistent.second);
+ if (!consistent.first)
{
cmOStringStream e;
e << "The INTERFACE_" << p << " property of \""
@@ -4608,7 +4639,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
}
else
{
- propContent = consistent;
+ propContent = consistent.second;
continue;
}
}