[libsecret/gcrypt-pkgconfig] meson: Check for gcrypt with pkg-config first



commit dc6a2cfb175c6d6992192d1ba3838252e82b7e7a
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Sat May 11 00:41:35 2019 +0100

    meson: Check for gcrypt with pkg-config first
    
    Some distributions patch libgcrypt to provide a pkg-config file, and
    disable libgcrypt-config. One of these distributions is Yocto, which we
    use as the basis for the GNOME Continuous build environment.
    
    We should check if there's a pkg-config file available for gcrypt, and
    use it, falling back to libgcrypt-config if the pkg-config file is not
    found.

 meson.build | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/meson.build b/meson.build
index 6a22ebc..36db806 100644
--- a/meson.build
+++ b/meson.build
@@ -45,17 +45,20 @@ glib_deps = [
 ]
 if with_gcrypt
   min_libgcrypt_version = '1.2.2'
-  libgcrypt_config = find_program('libgcrypt-config')
-  libgcrypt_version = run_command(libgcrypt_config, '--version').stdout().strip()
-  if (libgcrypt_version.version_compare('>' + libgcrypt_version))
-    error('@0@ requires at least gcrypt version @1@, but version found is @2@'
-            .format(meson.project_name(), min_libgcrypt_version, libgcrypt_version))
+  gcrypt_dep = dependency('libgcrypt', version: '>=' + min_libgcrypt_version, required: false)
+  if not gcrypt_dep.found()
+    libgcrypt_config = find_program('libgcrypt-config')
+    libgcrypt_version = run_command(libgcrypt_config, '--version').stdout().strip()
+    if (libgcrypt_version.version_compare('>' + libgcrypt_version))
+      error('@0@ requires at least gcrypt version @1@, but version found is @2@'
+              .format(meson.project_name(), min_libgcrypt_version, libgcrypt_version))
+    endif
+    message('gcrypt version: @0@'.format(libgcrypt_version))
+    gcrypt_dep = declare_dependency(
+      link_args: run_command(libgcrypt_config, '--libs').stdout().strip().split(),
+      compile_args: run_command(libgcrypt_config, '--cflags').stdout().strip().split(),
+    )
   endif
-  message('gcrypt version: @0@'.format(libgcrypt_version))
-  gcrypt_dep = declare_dependency(
-    link_args: run_command(libgcrypt_config, '--libs').stdout().strip().split(),
-    compile_args: run_command(libgcrypt_config, '--cflags').stdout().strip().split(),
-  )
 endif
 
 # Libraries


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