Generate autotools provided PACKAGE_.. and VERSION defines by a cmake macro.
authorRalf Habacker <ralf.habacker@freenet.de>
Wed, 28 Aug 2013 12:16:21 +0000 (14:16 +0200)
committerRalf Habacker <ralf.habacker@freenet.de>
Wed, 28 Aug 2013 12:50:57 +0000 (14:50 +0200)
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=67072
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
cmake/CMakeLists.txt
cmake/config.h.cmake
cmake/modules/MacrosAutotools.cmake

index aecc74c..bde43f0 100644 (file)
@@ -19,6 +19,14 @@ autoversion(../configure.ac dbus)
 # used by file version info
 set (DBUS_PATCH_VERSION "0")
 
+# set PACKAGE_... variables
+autopackage(
+    dbus
+    ${DBUS_VERSION_STRING}
+    "http://dbus.freedesktop.org"
+    "https://bugs.freedesktop.org/enter_bug.cgi?product=dbus"
+)
+
 include(Macros)
 TIMESTAMP(DBUS_BUILD_TIMESTAMP)
 
index 824b514..f14b169 100644 (file)
@@ -6,6 +6,12 @@
 /* indicate that we are building with cmake */
 #define DBUS_CMAKE 1
 
+@AUTOPACKAGE_CONFIG_H_TEMPLATE@
+
+/*
+ * Variables defined by AC_DEFINE in ../configure.ac
+ * should be placed in this file
+*/
 #cmakedefine HAVE_GNUC_VARARGS 1
 
 #cmakedefine DBUS_CONSOLE_AUTH_DIR "@DBUS_CONSOLE_AUTH_DIR@"
@@ -18,7 +24,6 @@
 #cmakedefine DBUS_SESSION_BUS_CONNECT_ADDRESS  "@DBUS_SESSION_BUS_CONNECT_ADDRESS@"
 #cmakedefine DBUS_MACHINE_UUID_FILE "@DBUS_MACHINE_UUID_FILE@"
 #cmakedefine DBUS_DAEMONDIR "@DBUS_DAEMONDIR@"
-#cmakedefine PACKAGE "@PACKAGE@"
 
 #cmakedefine DBUS_ENABLE_STATS
 
index ff30eaf..68e8ae5 100644 (file)
@@ -23,6 +23,66 @@ macro(autoversion config prefix)
 endmacro()
 
 #
+# Defines package related variables (PACKAGE_..., PACKAGE and VERSION)
+# as done by autotools.
+#
+# Additional it defines a cmake variable named PACKAGE_CONFIG_H_TEMPLATE
+# which could be placed in config.h templates to have those variables
+# defined at code level like shown below:
+#
+# config.h.template
+#   ...
+#   @AUTOPACKAGE_CONFIG_H_TEMPLATE@
+#   ...
+#
+macro(autopackage name version url support_url)
+    # Define to the full name of this package.
+    set(PACKAGE_NAME ${name})
+
+    # Define to the version of this package.
+    set(PACKAGE_VERSION ${version})
+
+    # Define to the home page for this package.
+    set(PACKAGE_URL ${url})
+
+    # Define to the address where bug reports for this package should be sent.
+    set(PACKAGE_BUGREPORT ${support_url})
+
+    # Define to the full name and version of this package.
+    set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
+
+    # Define to the one symbol short name of this package.
+    set(PACKAGE_TARNAME ${PACKAGE_NAME})
+
+    set(PACKAGE ${name})
+    set(VERSION ${DBUS_VERSION_STRING})
+
+    set(AUTOPACKAGE_CONFIG_H_TEMPLATE "/* generated by cmake macro autopackage */\n
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT \"@PACKAGE_BUGREPORT@\"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME \"@PACKAGE_NAME@\"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING \"@PACKAGE_STRING@\"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME \"@PACKAGE_TARNAME@\"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL \"@PACKAGE_URL@\"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION \"@PACKAGE_VERSION@\"
+
+/* defined by autotools package */
+#define PACKAGE \"@PACKAGE@\"
+#define VERSION \"@VERSION@\"
+")
+endmacro(autopackage)
+
+#
 # parses config.h template and create cmake equivalent 
 # not implemented yet
 #