[Cmake-commits] CMake branch, next, updated. v2.8.12.1-6447-gb176028

Stephen Kelly steveire at gmail.com
Fri Dec 27 06:57:54 EST 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  b176028b63d471ccdefab4511e21a8493c85ce6f (commit)
       via  6a58e6570c6bbc6cb504c7adc8843e353d1868c6 (commit)
       via  a41abd1ed828ea59aec8a5d541bc460c8afeeeb7 (commit)
      from  b49b96195a6749440eee306da74979e2e456f5d7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b176028b63d471ccdefab4511e21a8493c85ce6f
commit b176028b63d471ccdefab4511e21a8493c85ce6f
Merge: b49b961 6a58e65
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Dec 27 06:57:52 2013 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Fri Dec 27 06:57:52 2013 -0500

    Merge topic 'genex-numerics' into next
    
    6a58e65 Genex: Add EQUAL expression.
    a41abd1 cmTarget: Use strtol for numeric parsing.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6a58e6570c6bbc6cb504c7adc8843e353d1868c6
commit 6a58e6570c6bbc6cb504c7adc8843e353d1868c6
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Dec 27 12:42:37 2013 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Fri Dec 27 12:54:57 2013 +0100

    Genex: Add EQUAL expression.
    
    Support decimal, hex, octal and binary literals.

diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst
index ed28abd..12cfaf8 100644
--- a/Help/manual/cmake-generator-expressions.7.rst
+++ b/Help/manual/cmake-generator-expressions.7.rst
@@ -55,6 +55,8 @@ otherwise expands to nothing.
   ``0`` if ``?`` is ``1``, else ``1``
 ``$<STREQUAL:a,b>``
   ``1`` if ``a`` is STREQUAL ``b``, else ``0``
+``$<EQUAL:a,b>``
+  ``1`` if ``a`` is EQUAL ``b`` in a numeric comparison, else ``0``
 ``$<CONFIG:cfg>``
   ``1`` if config is ``cfg``, else ``0``. This is a case-insensitive comparison.
   The mapping in :prop_tgt:`MAP_IMPORTED_CONFIG_<CONFIG>` is also considered by
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index c8010d0..0b37198 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -19,6 +19,7 @@
 #include <cmsys/String.h>
 
 #include <assert.h>
+#include <errno.h>
 
 //----------------------------------------------------------------------------
 #if !defined(__SUNPRO_CC) || __SUNPRO_CC > 0x510
@@ -197,6 +198,58 @@ static const struct StrEqualNode : public cmGeneratorExpressionNode
 } strEqualNode;
 
 //----------------------------------------------------------------------------
+static const struct EqualNode : public cmGeneratorExpressionNode
+{
+  EqualNode() {}
+
+  virtual int NumExpectedParameters() const { return 2; }
+
+  std::string Evaluate(const std::vector<std::string> &parameters,
+                       cmGeneratorExpressionContext *context,
+                       const GeneratorExpressionContent *content,
+                       cmGeneratorExpressionDAGChecker *) const
+  {
+    char *pEnd;
+
+    int base = 0;
+
+    const char *lhs = parameters[0].c_str();
+    if (cmHasLiteralPrefix(lhs, "0b"))
+      {
+      base = 2;
+      lhs += 2;
+      }
+
+    long lnum = strtol(lhs, &pEnd, base);
+    if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE)
+      {
+      reportError(context, content->GetOriginalExpression(),
+            "$<EQUAL> parameter not a valid integer.");
+      return std::string();
+      }
+
+    base = 0;
+
+    const char *rhs = parameters[1].c_str();
+    if (cmHasLiteralPrefix(rhs, "0b"))
+      {
+      base = 2;
+      rhs += 2;
+      }
+
+    long rnum = strtol(rhs, &pEnd, base);
+    if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE)
+      {
+      reportError(context, content->GetOriginalExpression(),
+            "$<EQUAL> parameter not a valid integer.");
+      return std::string();
+      }
+
+    return lnum == rnum ? "1" : "0";
+  }
+} equalNode;
+
+//----------------------------------------------------------------------------
 static const struct LowerCaseNode : public cmGeneratorExpressionNode
 {
   LowerCaseNode() {}
@@ -1492,6 +1545,8 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier)
     return &targetSoNameFileDirNode;
   else if (identifier == "STREQUAL")
     return &strEqualNode;
+  else if (identifier == "EQUAL")
+    return &equalNode;
   else if (identifier == "LOWER_CASE")
     return &lowerCaseNode;
   else if (identifier == "UPPER_CASE")
diff --git a/Tests/CompatibleInterface/CMakeLists.txt b/Tests/CompatibleInterface/CMakeLists.txt
index 47e974a..350b518 100644
--- a/Tests/CompatibleInterface/CMakeLists.txt
+++ b/Tests/CompatibleInterface/CMakeLists.txt
@@ -60,7 +60,7 @@ set_property(TARGET CompatibleInterface PROPERTY STRING_PROP2 prop2)
 set_property(TARGET CompatibleInterface PROPERTY STRING_PROP3 prop3)
 set_property(TARGET CompatibleInterface PROPERTY NUMBER_MIN_PROP1 50)
 set_property(TARGET CompatibleInterface PROPERTY NUMBER_MIN_PROP2 250)
-set_property(TARGET CompatibleInterface PROPERTY NUMBER_MIN_PROP3 0xA)
+set_property(TARGET CompatibleInterface PROPERTY NUMBER_MIN_PROP3 0xa)
 set_property(TARGET CompatibleInterface PROPERTY NUMBER_MIN_PROP4 0x1A)
 set_property(TARGET CompatibleInterface PROPERTY NUMBER_MAX_PROP1 50)
 set_property(TARGET CompatibleInterface PROPERTY NUMBER_MAX_PROP2 250)
@@ -75,7 +75,7 @@ target_compile_definitions(CompatibleInterface
     $<$<STREQUAL:$<TARGET_PROPERTY:STRING_PROP3>,prop3>:STRING_PROP3>
     $<$<STREQUAL:$<TARGET_PROPERTY:NUMBER_MIN_PROP1>,50>:NUMBER_MIN_PROP1=50>
     $<$<STREQUAL:$<TARGET_PROPERTY:NUMBER_MIN_PROP2>,200>:NUMBER_MIN_PROP2=200>
-    $<$<STREQUAL:$<TARGET_PROPERTY:NUMBER_MIN_PROP3>,0xA>:NUMBER_MIN_PROP3=0xA>
+    $<$<EQUAL:$<TARGET_PROPERTY:NUMBER_MIN_PROP3>,0xA>:NUMBER_MIN_PROP3=0xA>
     $<$<STREQUAL:$<TARGET_PROPERTY:NUMBER_MIN_PROP4>,0x10>:NUMBER_MIN_PROP4=0x10>
     $<$<STREQUAL:$<TARGET_PROPERTY:NUMBER_MAX_PROP1>,100>:NUMBER_MAX_PROP1=100>
     $<$<STREQUAL:$<TARGET_PROPERTY:NUMBER_MAX_PROP2>,250>:NUMBER_MAX_PROP2=250>
diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt
index 892f80f..df896c4 100644
--- a/Tests/GeneratorExpression/CMakeLists.txt
+++ b/Tests/GeneratorExpression/CMakeLists.txt
@@ -196,6 +196,16 @@ add_custom_target(check-part3 ALL
     -Dlower_case=$<LOWER_CASE:Mi,XeD>
     -Dupper_case=$<UPPER_CASE:MiX,eD>
     -Dmake_c_identifier=$<MAKE_C_IDENTIFIER:4f,oo:+bar-$>
+    -Dequal1=$<EQUAL:1,2>
+    -Dequal2=$<EQUAL:1,1>
+    -Dequal3=$<EQUAL:0x1,1>
+    -Dequal4=$<EQUAL:0x1,2>
+    -Dequal5=$<EQUAL:0xA,0xa>
+    -Dequal6=$<EQUAL:0xA,10>
+    -Dequal7=$<EQUAL:0xA,012>
+    -Dequal8=$<EQUAL:10,012>
+    -Dequal9=$<EQUAL:10,010>
+    -Dequal10=$<EQUAL:10,0b1010>
     -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part3.cmake
   COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 3)"
   VERBATIM
diff --git a/Tests/GeneratorExpression/check-part3.cmake b/Tests/GeneratorExpression/check-part3.cmake
index 3361eeb..60e6c94 100644
--- a/Tests/GeneratorExpression/check-part3.cmake
+++ b/Tests/GeneratorExpression/check-part3.cmake
@@ -37,3 +37,13 @@ endforeach()
 check(lower_case "mi,xed")
 check(upper_case "MIX,ED")
 check(make_c_identifier "_4f_oo__bar__")
+check(equal1 "0")
+check(equal2 "1")
+check(equal3 "1")
+check(equal4 "0")
+check(equal5 "1")
+check(equal6 "1")
+check(equal7 "1")
+check(equal8 "1")
+check(equal9 "0")
+check(equal10 "1")

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a41abd1ed828ea59aec8a5d541bc460c8afeeeb7
commit a41abd1ed828ea59aec8a5d541bc460c8afeeeb7
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Thu Dec 26 16:04:58 2013 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Fri Dec 27 12:54:57 2013 +0100

    cmTarget: Use strtol for numeric parsing.
    
    On Windows apparently sscanf can not handle hex numbers.
    
    Test that numeric comparison works with hex numbers.

diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index a0177fb..4a102f9 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -24,6 +24,7 @@
 #include <set>
 #include <stdlib.h> // required for atof
 #include <assert.h>
+#include <errno.h>
 
 const char* cmTarget::GetTargetTypeName(TargetType targetType)
 {
@@ -4244,10 +4245,16 @@ cmMinimum(const T& l, const T& r) {return l < r ? l : r;}
 const char * consistentNumberProperty(const char *lhs, const char *rhs,
                                CompatibleType t)
 {
-  double lnum;
-  double rnum;
-  if(sscanf(lhs, "%lg", &lnum) != 1 ||
-      sscanf(rhs, "%lg", &rnum) != 1)
+  char *pEnd;
+
+  long lnum = strtol(lhs, &pEnd, 0);
+  if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE)
+    {
+    return 0;
+    }
+
+  long rnum = strtol(rhs, &pEnd, 0);
+  if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE)
     {
     return 0;
     }
diff --git a/Tests/CompatibleInterface/CMakeLists.txt b/Tests/CompatibleInterface/CMakeLists.txt
index 5e64d2a..47e974a 100644
--- a/Tests/CompatibleInterface/CMakeLists.txt
+++ b/Tests/CompatibleInterface/CMakeLists.txt
@@ -24,6 +24,8 @@ set_property(TARGET iface1 APPEND PROPERTY
   COMPATIBLE_INTERFACE_NUMBER_MIN
     NUMBER_MIN_PROP1
     NUMBER_MIN_PROP2
+    NUMBER_MIN_PROP3
+    NUMBER_MIN_PROP4
 )
 set_property(TARGET iface1 APPEND PROPERTY
   COMPATIBLE_INTERFACE_NUMBER_MAX
@@ -34,7 +36,7 @@ set_property(TARGET iface1 APPEND PROPERTY
 set(CMAKE_DEBUG_TARGET_PROPERTIES
   BOOL_PROP1 BOOL_PROP2 BOOL_PROP3 BOOL_PROP4
   STRING_PROP1 STRING_PROP2 STRING_PROP3
-  NUMBER_MIN_PROP1 NUMBER_MIN_PROP2
+  NUMBER_MIN_PROP1 NUMBER_MIN_PROP2 NUMBER_MIN_PROP3 NUMBER_MIN_PROP4
   NUMBER_MAX_PROP1 NUMBER_MAX_PROP2
 )
 
@@ -44,6 +46,8 @@ set_property(TARGET iface1 PROPERTY INTERFACE_STRING_PROP1 prop1)
 set_property(TARGET iface1 PROPERTY INTERFACE_STRING_PROP2 prop2)
 set_property(TARGET iface1 PROPERTY INTERFACE_NUMBER_MIN_PROP1 100)
 set_property(TARGET iface1 PROPERTY INTERFACE_NUMBER_MIN_PROP2 200)
+set_property(TARGET iface1 PROPERTY INTERFACE_NUMBER_MIN_PROP3 0x10)
+set_property(TARGET iface1 PROPERTY INTERFACE_NUMBER_MIN_PROP4 0x10)
 set_property(TARGET iface1 PROPERTY INTERFACE_NUMBER_MAX_PROP1 100)
 set_property(TARGET iface1 PROPERTY INTERFACE_NUMBER_MAX_PROP2 200)
 
@@ -56,6 +60,8 @@ set_property(TARGET CompatibleInterface PROPERTY STRING_PROP2 prop2)
 set_property(TARGET CompatibleInterface PROPERTY STRING_PROP3 prop3)
 set_property(TARGET CompatibleInterface PROPERTY NUMBER_MIN_PROP1 50)
 set_property(TARGET CompatibleInterface PROPERTY NUMBER_MIN_PROP2 250)
+set_property(TARGET CompatibleInterface PROPERTY NUMBER_MIN_PROP3 0xA)
+set_property(TARGET CompatibleInterface PROPERTY NUMBER_MIN_PROP4 0x1A)
 set_property(TARGET CompatibleInterface PROPERTY NUMBER_MAX_PROP1 50)
 set_property(TARGET CompatibleInterface PROPERTY NUMBER_MAX_PROP2 250)
 
@@ -69,6 +75,8 @@ target_compile_definitions(CompatibleInterface
     $<$<STREQUAL:$<TARGET_PROPERTY:STRING_PROP3>,prop3>:STRING_PROP3>
     $<$<STREQUAL:$<TARGET_PROPERTY:NUMBER_MIN_PROP1>,50>:NUMBER_MIN_PROP1=50>
     $<$<STREQUAL:$<TARGET_PROPERTY:NUMBER_MIN_PROP2>,200>:NUMBER_MIN_PROP2=200>
+    $<$<STREQUAL:$<TARGET_PROPERTY:NUMBER_MIN_PROP3>,0xA>:NUMBER_MIN_PROP3=0xA>
+    $<$<STREQUAL:$<TARGET_PROPERTY:NUMBER_MIN_PROP4>,0x10>:NUMBER_MIN_PROP4=0x10>
     $<$<STREQUAL:$<TARGET_PROPERTY:NUMBER_MAX_PROP1>,100>:NUMBER_MAX_PROP1=100>
     $<$<STREQUAL:$<TARGET_PROPERTY:NUMBER_MAX_PROP2>,250>:NUMBER_MAX_PROP2=250>
 )
diff --git a/Tests/CompatibleInterface/main.cpp b/Tests/CompatibleInterface/main.cpp
index fa299e9..e23625a 100644
--- a/Tests/CompatibleInterface/main.cpp
+++ b/Tests/CompatibleInterface/main.cpp
@@ -33,7 +33,9 @@ enum {
   NumericMaxTest1 = sizeof(CMakeStaticAssert<NUMBER_MAX_PROP1 == 100>),
   NumericMaxTest2 = sizeof(CMakeStaticAssert<NUMBER_MAX_PROP2 == 250>),
   NumericMinTest1 = sizeof(CMakeStaticAssert<NUMBER_MIN_PROP1 == 50>),
-  NumericMinTest2 = sizeof(CMakeStaticAssert<NUMBER_MIN_PROP2 == 200>)
+  NumericMinTest2 = sizeof(CMakeStaticAssert<NUMBER_MIN_PROP2 == 200>),
+  NumericMinTest3 = sizeof(CMakeStaticAssert<NUMBER_MIN_PROP3 == 0xA>),
+  NumericMinTest4 = sizeof(CMakeStaticAssert<NUMBER_MIN_PROP4 == 0x10>)
 };
 
 #include "iface2.h"

-----------------------------------------------------------------------

Summary of changes:
 Help/manual/cmake-generator-expressions.7.rst |    2 +
 Source/cmGeneratorExpressionEvaluator.cxx     |   55 +++++++++++++++++++++++++
 Source/cmTarget.cxx                           |   15 +++++--
 Tests/CompatibleInterface/CMakeLists.txt      |   10 ++++-
 Tests/CompatibleInterface/main.cpp            |    4 +-
 Tests/GeneratorExpression/CMakeLists.txt      |   10 +++++
 Tests/GeneratorExpression/check-part3.cmake   |   10 +++++
 7 files changed, 100 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list