Blob Blame History Raw
From 30ff4e9f57f7a8f736ffd39cf595fc7893c8d52b Mon Sep 17 00:00:00 2001
From: Milan Crha <mcrha@redhat.com>
Date: Tue, 19 Jul 2022 17:48:36 +0200
Subject: [PATCH] build: Use gcr4 by default, but have an option to use gcr3
 too

The gcr4 replaces gcr3, thus make it possible to use either of the two,
while defaulting to gcr4, as it'll live for a longer time.
---
 .gitlab-ci.yml                  | 2 +-
 meson.build                     | 7 ++++++-
 meson_options.txt               | 1 +
 plugins/wwan/gsd-wwan-manager.c | 4 ++++
 plugins/wwan/meson.build        | 2 +-
 5 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index dd67d8f4..ae37234d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -87,7 +87,7 @@ stages:
 .Build procedure: &build_procedure
   echo "== Building ==" &&
   rm -rf _build/ &&
-  meson . _build ${BUILD_OPTS} &&
+  meson . _build ${BUILD_OPTS} -Dgcr3=true &&
   ninja -C _build 2>&1 | tee compilation.log
 
 .Run Tests: &run_tests
diff --git a/meson.build b/meson.build
index 3e7cb50d..7f880d75 100644
--- a/meson.build
+++ b/meson.build
@@ -214,7 +214,12 @@ endif
 # wwan
 enable_wwan = get_option('wwan')
 if enable_wwan
-  gcr_base_dep = dependency('gcr-base-3', version: '>= 3.7.5')
+  if get_option('gcr3')
+     gcr_dep = dependency('gcr-base-3', version: '>= 3.7.5')
+     config_h.set10('HAVE_GCR3', 1)
+  else
+     gcr_dep = dependency('gcr-4', version: '>= 3.90.0')
+  endif
   mm_glib_dep = dependency('mm-glib', version: '>= 1.0')
 endif
 
diff --git a/meson_options.txt b/meson_options.txt
index 3e04cf64..a5eb354f 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -11,4 +11,5 @@ option('smartcard', type: 'boolean', value: true, description: 'build with smart
 option('usb-protection', type: 'boolean', value: true, description: 'build with usb-protection support')
 option('wayland', type: 'boolean', value: true, description: 'build with Wayland support')
 option('wwan', type: 'boolean', value: true, description: 'build with WWAN support')
+option('gcr3', type: 'boolean', value: false, description: 'build with gcr3, otherwise gcr4 is used')
 option('colord', type: 'boolean', value: true, description: 'build with colord support')
diff --git a/plugins/wwan/gsd-wwan-manager.c b/plugins/wwan/gsd-wwan-manager.c
index 42109ef8..c2288375 100644
--- a/plugins/wwan/gsd-wwan-manager.c
+++ b/plugins/wwan/gsd-wwan-manager.c
@@ -31,7 +31,11 @@
 #include <libmm-glib.h>
 
 #define GCR_API_SUBJECT_TO_CHANGE
+#ifdef HAVE_GCR3
 #include <gcr/gcr-base.h>
+#else
+#include <gcr/gcr.h>
+#endif
 
 #include "gnome-settings-profile.h"
 #include "cc-wwan-device.h"
diff --git a/plugins/wwan/meson.build b/plugins/wwan/meson.build
index 3f117fb3..238288c6 100644
--- a/plugins/wwan/meson.build
+++ b/plugins/wwan/meson.build
@@ -4,7 +4,7 @@ sources = files(
   'main.c'
 )
 
-deps = plugins_deps + [gio_dep, gcr_base_dep, mm_glib_dep, polkit_gobject_dep]
+deps = plugins_deps + [gio_dep, gcr_dep, mm_glib_dep, polkit_gobject_dep]
 
 cflags += ['-DGNOMECC_DATA_DIR="@0@"'.format(gsd_pkgdatadir)]
 
-- 
2.35.1