summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2015-03-03 13:17:27 +0100
committerRalf Habacker <ralf.habacker@freenet.de>2015-03-03 16:37:32 +0100
commitdca6591fa21371d4aa8511af61006c706990215c (patch)
treecb6262e7239fbbb7c5e52191d007f670b0a40071 /cmake
parent38e64d75715c7bd524e93dc61f62a0c34449f683 (diff)
downloaddbus-dca6591fa21371d4aa8511af61006c706990215c.tar.gz
Keep cmake defines GLIB_VERSION_... in sync with autotools.
This patch adds autotools related cmake macros autoinit() and autodefine(). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89284 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/CMakeLists.txt8
-rw-r--r--cmake/config.h.cmake4
-rw-r--r--cmake/modules/MacrosAutotools.cmake51
3 files changed, 51 insertions, 12 deletions
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index adc6d4b2..69221296 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -15,7 +15,8 @@ endif(COMMAND cmake_policy)
# detect version
include(MacrosAutotools)
-autoversion(../configure.ac dbus)
+autoinit(../configure.ac)
+autoversion(dbus)
# used by file version info
set (DBUS_PATCH_VERSION "0")
@@ -183,6 +184,11 @@ if (UNIX AND NOT DBUS_DISABLE_ASSERT)
add_definitions(-DDBUS_BUILT_R_DYNAMIC)
endif (UNIX AND NOT DBUS_DISABLE_ASSERT)
+if(DBUS_WITH_GLIB)
+ autodefine(GLIB_VERSION_MIN_REQUIRED)
+ autodefine(GLIB_VERSION_MAX_ALLOWED)
+endif()
+
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
#########################################################################
diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake
index cd4720c9..88c2caa3 100644
--- a/cmake/config.h.cmake
+++ b/cmake/config.h.cmake
@@ -96,6 +96,10 @@
#cmakedefine DBUS_VA_COPY_AS_ARRAY @DBUS_VA_COPY_AS_ARRAY@
+#cmakedefine DBUS_WITH_GLIB 1
+#cmakedefine GLIB_VERSION_MIN_REQUIRED @GLIB_VERSION_MIN_REQUIRED@
+#cmakedefine GLIB_VERSION_MAX_ALLOWED @GLIB_VERSION_MAX_ALLOWED@
+
// headers
/* Define to 1 if you have dirent.h */
#cmakedefine HAVE_DIRENT_H 1
diff --git a/cmake/modules/MacrosAutotools.cmake b/cmake/modules/MacrosAutotools.cmake
index 2b1c59d4..a218db9a 100644
--- a/cmake/modules/MacrosAutotools.cmake
+++ b/cmake/modules/MacrosAutotools.cmake
@@ -1,6 +1,21 @@
#
+# cmake package for autotools support
+#
# @Author Ralf Habacker
#
+
+#
+# load autotools configure file into an internal list named _configure_ac
+#
+macro(autoinit config)
+ set(_configure_ac_name ${config})
+ file(READ ${config} _configure_ac_raw)
+ # Convert file contents into a CMake list (where each element in the list
+ # is one line of the file)
+ STRING(REGEX REPLACE ";" "\\\\;" _configure_ac "${_configure_ac_raw}")
+ STRING(REGEX REPLACE "\n" ";" _configure_ac "${_configure_ac}")
+endmacro()
+
# extracts version information from autoconf config file
# and set related cmake variables
#
@@ -14,17 +29,16 @@
# ${prefix}_LIBRARY_REVISION
# ${prefix}_LIBRARY_CURRENT
#
-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}")
- string (REGEX REPLACE ".*LT_AGE=([0-9]+).*" "\\1" ${prefix_upper}_LIBRARY_AGE ${_configure_ac})
- string (REGEX REPLACE ".*LT_CURRENT=([0-9]+).*" "\\1" ${prefix_upper}_LIBRARY_CURRENT ${_configure_ac})
- string (REGEX REPLACE ".*LT_REVISION=([0-9]+).*" "\\1" ${prefix_upper}_LIBRARY_REVISION ${_configure_ac})
+macro(autoversion prefix)
+ string(TOUPPER ${prefix} prefix_upper)
+ string (REGEX REPLACE ".*${prefix}_major_version], .([0-9]+).*" "\\1" ${prefix_upper}_MAJOR_VERSION ${_configure_ac_raw})
+ string (REGEX REPLACE ".*${prefix}_minor_version], .([0-9]+).*" "\\1" ${prefix_upper}_MINOR_VERSION ${_configure_ac_raw})
+ string (REGEX REPLACE ".*${prefix}_micro_version], .([0-9]+).*" "\\1" ${prefix_upper}_MICRO_VERSION ${_configure_ac_raw})
+ set (${prefix_upper}_VERSION ${${prefix_upper}_MAJOR_VERSION}.${${prefix_upper}_MINOR_VERSION}.${${prefix_upper}_MICRO_VERSION})
+ set (${prefix_upper}_VERSION_STRING "${${prefix_upper}_VERSION}")
+ string (REGEX REPLACE ".*LT_AGE=([0-9]+).*" "\\1" ${prefix_upper}_LIBRARY_AGE ${_configure_ac_raw})
+ string (REGEX REPLACE ".*LT_CURRENT=([0-9]+).*" "\\1" ${prefix_upper}_LIBRARY_CURRENT ${_configure_ac_raw})
+ string (REGEX REPLACE ".*LT_REVISION=([0-9]+).*" "\\1" ${prefix_upper}_LIBRARY_REVISION ${_configure_ac_raw})
endmacro()
#
@@ -88,6 +102,21 @@ macro(autopackage name version url support_url)
endmacro(autopackage)
#
+# define a cmake variable from autotools AC_DEFINE statement
+#
+macro(autodefine name)
+ foreach(line ${_configure_ac})
+ if(line MATCHES ".*AC_DEFINE(.*${name}.*).*")
+ string (REGEX REPLACE ".*AC_DEFINE(.*).*" "\\1" value ${line})
+ string (REGEX REPLACE ".*,(.*),.*" "\\1" value2 ${value})
+ string (REPLACE "[" "" value3 ${value2})
+ string (REPLACE "]" "" value4 ${value3})
+ set(${name} ${value4})
+ endif()
+ endforeach()
+endmacro()
+
+#
# parses config.h template and create cmake equivalent
# not implemented yet
#