[libnma/lr/gcr-gtk4: 6/6] meson: enable GCR support for libnma-gtk4




commit 1f3d8e27820b6956e847e1679fc492c46cda08ae
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Tue Mar 8 21:03:43 2022 +0100

    meson: enable GCR support for libnma-gtk4

 meson.build       | 29 +++++++++++++++++++++++++----
 meson_options.txt |  1 +
 src/meson.build   | 21 +++++++++++++++------
 3 files changed, 41 insertions(+), 10 deletions(-)
---
diff --git a/meson.build b/meson.build
index 0ca5e516..1571f01a 100644
--- a/meson.build
+++ b/meson.build
@@ -185,10 +185,6 @@ libnm_dep = declare_dependency(
   compile_args: cflags
 )
 
-# No such thing yet, just same lame duck placeholders.
-# it may actually end up being called differently.
-config_h.set10('WITH_GCR_GTK4', false)
-
 # GCR API is declared subject to change, do an extensive check of the prototypes
 gcr_api_check_src = '''
   #ifndef GCR_API_SUBJECT_TO_CHANGE
@@ -270,6 +266,31 @@ if enable_gcr
 endif
 config_h.set10('WITH_GCR', enable_gcr)
 
+# GCR for PKCS#11 enabled certificate chooser for libnma-gtk4
+enable_gcr_gtk4 = get_option('gcr_gtk4')
+if enable_gcr_gtk4
+  assert(enable_libnma_gtk4, 'gcr-gtk4 support was requested, but the libnma-gtk4 build was not enabled.')
+
+  deps = [
+    dependency('gcr-gtk4-3', version: '>= 3.90'),
+    dependency('gck-1', version: '>= 3.90')
+  ]
+
+  cflags = [
+    '-DGCR_API_SUBJECT_TO_CHANGE',
+    '-DGCK_API_SUBJECT_TO_CHANGE'
+  ]
+
+  # GCR API is declared subject to change, do an extensive check of the prototypes
+  assert(cc.compiles(gcr_api_check_src, dependencies: deps), 'gcr-gtk4 support was requested with 
-Dgcr_gtk4=true, but the gcr-gtk4 library is not available.')
+
+  gcr_gtk4_dep = declare_dependency(
+    dependencies: deps,
+    compile_args: cflags
+  )
+endif
+config_h.set10('WITH_GCR_GTK4', enable_gcr_gtk4)
+
 # introspection support
 enable_introspection = get_option('introspection')
 if enable_introspection
diff --git a/meson_options.txt b/meson_options.txt
index cc6f30d0..1dd1354c 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,5 +1,6 @@
 option('libnma_gtk4', type: 'boolean', value: false, description: 'build EXPERIMENTAL library libnma-gtk4 
for use with GTK4')
 option('gcr', type: 'boolean', value: true, description: 'Enable advanced certificate chooser.')
+option('gcr_gtk4', type: 'boolean', value: false, description: 'Enable advanced certificate chooser for 
EXPERIMENTAL library libnma-gtk4.')
 option('more_asserts', type: 'string', value: '0', description: 'Enable more assertions for debugging.')
 option('iso_codes', type: 'boolean', value: true, description: 'check for iso-codes at build-time')
 option('mobile_broadband_provider_info', type: 'boolean', value: true, description: 'check for 
mobile-broadband-provider-info at build-time')
diff --git a/src/meson.build b/src/meson.build
index 2064ddb0..1fdea6d7 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -61,6 +61,11 @@ gir_sources = [version_header] + nma_ws_sources + files(
   'nma-wifi-dialog.c'
 )
 
+pkcs11_sources = files(
+  'nma-pkcs11-cert-chooser-dialog.c',
+  'nma-pkcs11-token-login-dialog.c'
+)
+
 incs = [
   top_inc,
   shared_inc,
@@ -89,10 +94,7 @@ symbol_map = join_paths(meson.current_source_dir(), 'libnma.ver')
 nma_deps = [ deps, gtk_dep ]
 nma_sources = [ gir_sources, built_sources ]
 if enable_gcr
-  nma_sources += files(
-    'nma-pkcs11-cert-chooser-dialog.c',
-    'nma-pkcs11-token-login-dialog.c'
-  )
+  nma_sources += pkcs11_sources
   nma_deps += gcr_dep
 endif
 
@@ -115,12 +117,19 @@ libnma_dep = declare_dependency(
 )
 
 if enable_libnma_gtk4
+  nma_gtk4_deps = [ deps, gtk4_dep ]
+  nma_gtk4_sources = [ gir_sources, built_sources ]
+  if enable_gcr_gtk4
+    nma_gtk4_sources += pkcs11_sources
+    nma_gtk4_deps += gcr_gtk4_dep
+  endif
+
   libnma_gtk4 = shared_library(
     'nma-gtk4',
-    sources: gir_sources + built_sources,
+    sources: nma_gtk4_sources,
     version: libversion,
     include_directories: incs,
-    dependencies: [ deps, gtk4_dep ],
+    dependencies: nma_gtk4_deps,
     c_args: cflags,
     link_args: '-Wl,--version-script,' + symbol_map,
     link_depends: symbol_map,


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