[pan/wip/smcv/target-specific-glib] build: Target a specific GLib API version




commit 98132d76fe6992a8547f760a4dbc7609a81ed60a
Author: Simon McVittie <smcv debian org>
Date:   Tue Aug 17 10:22:20 2021 +0100

    build: Target a specific GLib API version
    
    Since GLib 2.32 (2012), setting GLIB_VERSION_MIN_REQUIRED selects the
    minimum required version of GLib for this project. Code that was
    deprecated after that version will not cause deprecation warnings, and
    where header files have changed their compile-time behaviour over time,
    the behaviour that was seen in the selected version will be used where
    possible. pan officially only requires GLib 2.17 if D-Bus is not enabled,
    but 2.26 is required for D-Bus and is also the oldest version for which
    version macros are provided, so behave as though that is the minimum.
    
    In particular, this disables new C++ behaviour introduced in GLib 2.68,
    which caused this project to fail to build.
    
    Similarly, setting GLIB_VERSION_MAX_ALLOWED causes GLib to emit warnings
    if a function introduced after the selected version is used, even inside
    a GLIB_CHECK_VERSION guard. The newest GLIB_CHECK_VERSION in pan seems
    to be for GLib 2.36 (2013), so use that.
    
    Resolves: https://gitlab.gnome.org/GNOME/pan/-/issues/128
    Signed-off-by: Simon McVittie <smcv debian org>

 configure.ac | 10 ++++++++++
 1 file changed, 10 insertions(+)
---
diff --git a/configure.ac b/configure.ac
index 69a1d4d2..a986003d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -112,6 +112,16 @@ if test "x$want_dbus" = "xyes" ; then
 else
   AM_PATH_GLIB_2_0($GLIB_REQUIRED,,exit 1,gobject gmodule gthread)
 fi
+dnl Silence deprecation warnings for things deprecated before 2.26,
+dnl and generally set the target behaviour to be like GLib 2.26.
+dnl In principle this should match $GLIB_REQUIRED, but 2.26 is the oldest
+dnl version for which the macros exist (and has been unsupported since
+dnl around 2011 in any case).
+GLIB_CFLAGS="$GLIB_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26"
+dnl Highest version number from which new features are allowed to be used,
+dnl even within a GLIB_CHECK_VERSION check. GLib will produce compile-time
+dnl warnings when features of a newer GLib version are used.
+GLIB_CFLAGS="$GLIB_CFLAGS -DGLIB_VERSION_MAX_ALLOWED=G_ENCODE_VERSION\\(2,36\\)"
 
 dnl Check for GMime
 AC_ARG_WITH([gmime30],


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]