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