Blob Blame History Raw
--- plplot-5.9.4/cmake/modules/plplot.cmake.transform_version	2009-05-10 13:37:17.000000000 -0600
+++ plplot-5.9.4/cmake/modules/plplot.cmake	2009-08-26 10:33:56.174638294 -0600
@@ -30,21 +30,41 @@
 
 # Useful macros....
 
-macro(TRANSFORM_VERSION _numerical_result _version)
-# _version must be a period-delimited triplet string of the form
-# "major.minor.patch".
-# This macro transforms that into a numerical result that can be compared.
-if(${_version} MATCHES "^[0-9]*\\.[0-9]*\\.[0-9]*$")
-  string(REGEX REPLACE "^([0-9]*)\\.[0-9]*\\.[0-9]*$" "\\1" _major ${_version})
-  string(REGEX REPLACE "^[0-9]*\\.([0-9]*)\\.[0-9]*$" "\\1" _minor ${_version})
-  string(REGEX REPLACE "^[0-9]*\\.[0-9]*\\.([0-9]*)$" "\\1" _patch ${_version})
-  math(EXPR ${_numerical_result}
-  "${_major}*1000000 + ${_minor}*1000 + ${_patch}
-  ")
-else(${_version} MATCHES "^[0-9]*\\.[0-9]*\\.[0-9]*$")
-  set(${_numerical_result} 0)
-endif(${_version} MATCHES "^[0-9]*\\.[0-9]*\\.[0-9]*$")
-endmacro(TRANSFORM_VERSION)
+function(TRANSFORM_VERSION numerical_result version)
+  # internal_version ignores everything in version after any character that
+  # is not 0-9 or ".".  This should take care of the case when there is
+  # some non-numerical data in the patch version.
+  #message(STATUS "DEBUG: version = ${version}")
+  string(REGEX REPLACE "^([0-9.]+).*$" "\\1" internal_version ${version})
+
+  # internal_version is normally a period-delimited triplet string of the form
+  # "major.minor.patch", but patch and/or minor could be missing.
+  # Transform internal_version into a numerical result that can be compared.
+  string(REGEX REPLACE "^([0-9]*).+$" "\\1" major ${internal_version})
+  string(REGEX REPLACE "^[0-9]*\\.([0-9]*).*$" "\\1" minor ${internal_version})
+  string(REGEX REPLACE "^[0-9]*\\.[0-9]*\\.([0-9]*)$" "\\1" patch ${internal_version})
+
+  if(NOT patch MATCHES "[0-9]+")
+    set(patch 0)
+  endif(NOT patch MATCHES "[0-9]+")
+  
+  if(NOT minor MATCHES "[0-9]+")
+    set(minor 0)
+  endif(NOT minor MATCHES "[0-9]+")
+  
+  if(NOT major MATCHES "[0-9]+")
+    set(major 0)
+  endif(NOT major MATCHES "[0-9]+")
+  #message(STATUS "DEBUG: internal_version = ${internal_version}")
+  #message(STATUS "DEBUG: major = ${major}")
+  #message(STATUS "DEBUG: minor= ${minor}")
+  #message(STATUS "DEBUG: patch = ${patch}")
+  math(EXPR internal_numerical_result
+    "${major}*1000000 + ${minor}*1000 + ${patch}"
+    )
+  #message(STATUS "DEBUG: ${numerical_result} = ${internal_numerical_result}")
+  set(${numerical_result} ${internal_numerical_result} PARENT_SCOPE)
+endfunction(TRANSFORM_VERSION)
 
 macro(split_libraries_list _list _list_general _list_debug _list_optimized)
   # Macro for splitting a libraries list into its keyword denoted general,