project(dbus)
-#########################################################################
-# detect version
-#########################################################################
-file (READ ../configure.ac configure_ac)
-string (REGEX REPLACE ".*dbus_major_version], .([0-9]+).*" "\\1" DBUS_MAJOR_VERSION ${configure_ac})
-string (REGEX REPLACE ".*dbus_minor_version], .([0-9]+).*" "\\1" DBUS_MINOR_VERSION ${configure_ac})
-string (REGEX REPLACE ".*dbus_micro_version], .([0-9]+).*" "\\1" DBUS_MICRO_VERSION ${configure_ac})
-# used by file version info
-set (DBUS_PATCH_VERSION "0")
-set (DBUS_VERSION ${DBUS_MAJOR_VERSION}.${DBUS_MINOR_VERSION}.${DBUS_MICRO_VERSION})
-
-set (DBUS_VERSION_STRING "${DBUS_VERSION}")
-
# we need to be up to date
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.4 FATAL_ERROR)
if(COMMAND cmake_policy)
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/modules")
+# detect version
+include(MacrosAutotools)
+autoversion(../configure.ac dbus)
+# used by file version info
+set (DBUS_PATCH_VERSION "0")
+
include(Macros)
TIMESTAMP(DBUS_BUILD_TIMESTAMP)
--- /dev/null
+#
+# @Author Ralf Habacker
+#
+# extracts version information from autoconf config file
+# and set related cmake variables
+#
+# returns
+# ${prefix}_VERSION
+# ${prefix}_VERSION_STRING
+# ${prefix}_MAJOR_VERSION
+# ${prefix}_MINOR_VERSION
+# ${prefix}_MICRO_VERSION
+#
+macro(autoversion config prefix)
+ file (READ ${config} _configure_ac)
+ string(TOUPPER ${prefix} prefix_upper)
+ string (REGEX REPLACE ".*${prefix}_major_version], .([0-9]+).*" "\\1" ${prefix_upper}_MAJOR_VERSION ${_configure_ac})
+ string (REGEX REPLACE ".*${prefix}_minor_version], .([0-9]+).*" "\\1" ${prefix_upper}_MINOR_VERSION ${_configure_ac})
+ string (REGEX REPLACE ".*${prefix}_micro_version], .([0-9]+).*" "\\1" ${prefix_upper}_MICRO_VERSION ${_configure_ac})
+ set (${prefix_upper}_VERSION ${${prefix_upper}_MAJOR_VERSION}.${${prefix_upper}_MINOR_VERSION}.${${prefix_upper}_MICRO_VERSION})
+ set (${prefix_upper}_VERSION_STRING "${${prefix_upper}_VERSION}")
+
+endmacro()
+
+#
+# parses config.h template and create cmake equivalent
+# not implemented yet
+#
+macro(autoconfig template output)
+ file(READ ${template} contents)
+ # Convert file contents into a CMake list (where each element in the list
+ # is one line of the file)
+ STRING(REGEX REPLACE ";" "\\\\;" contents "${contents}")
+ STRING(REGEX REPLACE "\n" ";" contents "${contents}")
+ foreach(line contents)
+ message(STATUS ${line})
+ # find #undef lines
+ # append to config.h #define <variable-name> <variable-content>
+ endforeach()
+endmacro()