Home | History | Annotate | Download | only in modules
      1 #
      2 # @Author Ralf Habacker
      3 # 
      4 # extracts version information from autoconf config file
      5 # and set related cmake variables
      6 # 
      7 # returns  
      8 #   ${prefix}_VERSION
      9 #   ${prefix}_VERSION_STRING
     10 #   ${prefix}_MAJOR_VERSION
     11 #   ${prefix}_MINOR_VERSION
     12 #   ${prefix}_MICRO_VERSION
     13 # 
     14 macro(autoversion config prefix)
     15 	file (READ ${config} _configure_ac)
     16 	string(TOUPPER ${prefix} prefix_upper)
     17 	string (REGEX REPLACE ".*${prefix}_major_version], .([0-9]+).*" "\\1" ${prefix_upper}_MAJOR_VERSION ${_configure_ac})
     18 	string (REGEX REPLACE ".*${prefix}_minor_version], .([0-9]+).*" "\\1" ${prefix_upper}_MINOR_VERSION ${_configure_ac})
     19 	string (REGEX REPLACE ".*${prefix}_micro_version], .([0-9]+).*" "\\1" ${prefix_upper}_MICRO_VERSION ${_configure_ac})
     20 	set (${prefix_upper}_VERSION ${${prefix_upper}_MAJOR_VERSION}.${${prefix_upper}_MINOR_VERSION}.${${prefix_upper}_MICRO_VERSION})
     21 	set (${prefix_upper}_VERSION_STRING "${${prefix_upper}_VERSION}")
     22 
     23 endmacro()
     24 
     25 #
     26 # parses config.h template and create cmake equivalent 
     27 # not implemented yet
     28 # 
     29 macro(autoconfig template output)
     30 	file(READ ${template} contents)
     31 	# Convert file contents into a CMake list (where each element in the list
     32 	# is one line of the file)
     33 	STRING(REGEX REPLACE ";" "\\\\;" contents "${contents}")
     34 	STRING(REGEX REPLACE "\n" ";" contents "${contents}")
     35 	foreach(line contents)
     36 		message(STATUS ${line})
     37 		# find #undef lines
     38 		# append to config.h #define <variable-name> <variable-content>
     39 	endforeach()
     40 endmacro()
     41