[MOAB-dev] r1556 - in MOAB/trunk: . cmake

kraftche at mcs.anl.gov kraftche at mcs.anl.gov
Thu Jan 24 15:15:22 CST 2008


Author: kraftche
Date: 2008-01-24 15:15:22 -0600 (Thu, 24 Jan 2008)
New Revision: 1556

Added:
   MOAB/trunk/cmake/GetAcInitVersion.cmake
Modified:
   MOAB/trunk/CMakeLists.txt
   MOAB/trunk/cmake/AutoconfHeader.cmake
Log:
o Make CMake build get MOAB version from AC_INIT macro in configure.in
   (my continuing mission to specify the version in only one place)
o Also define "MB_VERSION" pre-processor macro in MBVersion.h
o If no patch level, leave MB_VERSION_PATCH undefined, rather than
   defining it to nothing.  This is closer to autotools behavior.
o Make appending "(beta)" or "(alpha)" to version string consistent
   with autotools behavior.

Note: also fixes wrong version number in CMakeList.txt


   


Modified: MOAB/trunk/CMakeLists.txt
===================================================================
--- MOAB/trunk/CMakeLists.txt	2008-01-23 04:58:24 UTC (rev 1555)
+++ MOAB/trunk/CMakeLists.txt	2008-01-24 21:15:22 UTC (rev 1556)
@@ -1,20 +1,21 @@
 project( MOAB )
 
-  set ( MOAB_VERSION_MAJOR 3 )
-  set ( MOAB_VERSION_MINOR 0 )
-  # Define this for release versions. Undefine it for beta versions.
-  #set ( MOAB_VERSION_PATCH 0 )
+  include( ${MOAB_SOURCE_DIR}/cmake/GetAcInitVersion.cmake )
+  get_ac_init_version()
+  set ( MOAB_VERSION_MAJOR  "${MAJOR_VERSION}"  )
+  set ( MOAB_VERSION_MINOR  "${MINOR_VERSION}"  )
+  set ( MOAB_VERSION        "${VERSION_STRING}" )
+  set ( MOAB_VERSION_STRING "${VERSION_STRING}" )
+  if ( DEFINED PATCH_VERSION )
+    set ( MOAB_VERSION_PATCH "${PATCH_VERSION}" )
+  else ( DEFINED PATCH_VERSION )
+    if ( MOAB_VERSION_MINOR EQUAL 99 )
+      set ( MOAB_VERSION_STRING "${MOAB_VERSION_STRING} (alpha)" )
+    else ( MOAB_VERSION_MINOR EQUAL 99 )
+      set ( MOAB_VERSION_STRING "${MOAB_VERSION_STRING} (beta)" )
+    endif ( MOAB_VERSION_MINOR EQUAL 99 )
+  endif ( NOT DEFINED PATCH_VERSION )
 
-  set ( MOAB_VERSION_STRING "${MOAB_VERSION_MAJOR}" )
-  if ( DEFINED MOAB_VERSION_MINOR )
-    set ( MOAB_VERSION_STRING "${MOAB_VERSION_STRING}.${MOAB_VERSION_MINOR}" )
-    if ( DEFINED MOAB_VERSION_PATCH )
-      set ( MOAB_VERSION_STRING "${MOAB_VERSION_STRING}.${MOAB_VERSION_PATCH}" )
-    else ( DEFINED MOAB_VERSION_PATCH )
-      set ( MOAB_VERSION_STRING "${MOAB_VERSION_STRING} (Beta)" )
-    endif ( DEFINED MOAB_VERSION_PATCH )
-  endif ( DEFINED MOAB_VERSION_MINOR )
-
   set ( CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${MOAB_SOURCE_DIR}/cmake" )
   set ( EXECUTABLE_OUTPUT_PATH ${MOAB_BINARY_DIR}/bin CACHE PATH "Path to executables" FORCE )
   set ( LIBRARY_OUTPUT_PATH    ${MOAB_BINARY_DIR}/bin CACHE PATH "Path to libraries"   FORCE )
@@ -271,9 +272,12 @@
 
   include( ${MOAB_SOURCE_DIR}/cmake/AutoconfHeader.cmake )
   # Define some more variables so they will be substituted properly in the autoconf files.
+  set( MB_VERSION        ${MOAB_VERSION}       )
   set( MB_VERSION_MAJOR  ${MOAB_VERSION_MAJOR} )
   set( MB_VERSION_MINOR  ${MOAB_VERSION_MINOR} )
-  set( MB_VERSION_PATCH  ${MOAB_VERSION_PATCH} )
+  if ( DEFINED MOAB_VERSION_PATCH )
+    set( MB_VERSION_PATCH  ${MOAB_VERSION_PATCH} )
+  endif ( DEFINED MOAB_VERSION_PATCH )
   set( MB_VERSION_STRING "\"${MOAB_VERSION_STRING}\"" )
 
   autoconf_header( ${MOAB_SOURCE_DIR}/MBVersion.h.in ${MOAB_BINARY_DIR}/MBVersion.h )

Modified: MOAB/trunk/cmake/AutoconfHeader.cmake
===================================================================
--- MOAB/trunk/cmake/AutoconfHeader.cmake	2008-01-23 04:58:24 UTC (rev 1555)
+++ MOAB/trunk/cmake/AutoconfHeader.cmake	2008-01-24 21:15:22 UTC (rev 1556)
@@ -11,9 +11,9 @@
     string( REGEX REPLACE "#undef ${VAR}\n" "#define ${VAR} ${${VAR}}\n" autoconf_HEADER "${autoconf_HEADER}" )
   endif ( ${VAR} )
   # ... but always define version numbers, even if they have "0" as a value
-  if ( \"${VAR}\" MATCHES ".*VERSION.*" )
-    string( REGEX REPLACE "#undef ${VAR}\n" "#define ${VAR} ${${VAR}}\n" autoconf_HEADER "${autoconf_HEADER}" )
-  endif ( \"${VAR}\" MATCHES ".*VERSION.*" )
+#  if ( \"${VAR}\" MATCHES ".*VERSION.*" )
+#    string( REGEX REPLACE "#undef ${VAR}\n" "#define ${VAR} ${${VAR}}\n" autoconf_HEADER "${autoconf_HEADER}" )
+#  endif ( \"${VAR}\" MATCHES ".*VERSION.*" )
 endforeach ( VAR )
 string( CONFIGURE "${autoconf_HEADER}"  autoconf_HEADER_OUT )
 

Added: MOAB/trunk/cmake/GetAcInitVersion.cmake
===================================================================
--- MOAB/trunk/cmake/GetAcInitVersion.cmake	                        (rev 0)
+++ MOAB/trunk/cmake/GetAcInitVersion.cmake	2008-01-24 21:15:22 UTC (rev 1556)
@@ -0,0 +1,20 @@
+# Read the package version number specified as the second argument
+# to the AC_INIT macro in a GNU Autoconf configure.in file.
+#
+# Define the following variables:
+# VERSION_STRING:  The second argument to AC_INIT
+# MAJOR_VERSION:   For a version string of the form m.n.p..., m
+# MINOR_VERSION:   For a version string of the form m.n.p..., n
+# PATCH_VERSION:   For a version string of the form m.n.p..., p
+
+macro ( get_ac_init_version )
+
+file( READ "configure.in" configure_IN )
+string( REGEX REPLACE "^.*AC_INIT *\\([^,]+, *([^, )]+).*$" "\\1" VERSION_STRING "${configure_IN}" )
+string( REGEX REPLACE "^([0-9]+)(\\..*)?$" "\\1" MAJOR_VERSION "${VERSION_STRING}" )
+string( REGEX REPLACE "^[0-9]+\\.([0-9]+)(\\..*)?$" "\\1" MINOR_VERSION "${VERSION_STRING}" )
+if ( VERSION_STRING MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+" )
+  string( REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" PATCH_VERSION "${VERSION_STRING}" )
+endif ( VERSION_STRING MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+" )
+
+endmacro( get_ac_init_version )




More information about the moab-dev mailing list