[gvfs] build: Check libgcrypt with pkg-config



commit 331cac472ff51bc2822ca3cc4a72cd37f3ce6d44
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Thu Apr 5 19:24:14 2018 +0200

    build: Check libgcrypt with pkg-config
    
    libgcrypt is usually distributed without a `.pc` file so
    `pkg-config` cannot be used to check its compiler and linker flags.
    However, some system might distribute it with a `.pc` file.
    
    The way libgcrypt dependency is checked has been changed by trying
    to check if it can be detected by using `pkg-config`, and if this
    fails, it fallbacks to `libgcrypt-config`.

 meson.build |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/meson.build b/meson.build
index 665d284..9862c41 100644
--- a/meson.build
+++ b/meson.build
@@ -239,19 +239,22 @@ enable_gcrypt = get_option('gcrypt')
 if enable_gcrypt
   libgcrypt_req_version = '>= 1.2.2'
 
-  libgcrypt_config = find_program('libgcrypt-config')
-  libgcrypt_version = run_command(libgcrypt_config, '--version').stdout().strip()
+  libgcrypt_dep = dependency('libgcrypt', version: libgcrypt_req_version, required: false)
+  if not libgcrypt_dep.found()
+    libgcrypt_config = find_program('libgcrypt-config')
+    libgcrypt_version = run_command(libgcrypt_config, '--version').stdout().strip()
 
-  assert(libgcrypt_version.version_compare(libgcrypt_req_version), 'gcrypt required but libgcrypt ' + 
libgcrypt_req_version + ' not found')
+    assert(libgcrypt_version.version_compare(libgcrypt_req_version), 'gcrypt required but libgcrypt ' + 
libgcrypt_req_version + ' not found')
 
-  libgcrypt_cflags = run_command(libgcrypt_config, '--cflags').stdout().strip().split()
-  libgcrypt_libs = run_command(libgcrypt_config, '--libs').stdout().strip().split()
+    libgcrypt_cflags = run_command(libgcrypt_config, '--cflags').stdout().strip().split()
+    libgcrypt_libs = run_command(libgcrypt_config, '--libs').stdout().strip().split()
 
-  libgcrypt_dep = declare_dependency(
-    compile_args: libgcrypt_cflags,
-    link_args: libgcrypt_libs,
-    version: libgcrypt_version
-  )
+    libgcrypt_dep = declare_dependency(
+      compile_args: libgcrypt_cflags,
+      link_args: libgcrypt_libs,
+      version: libgcrypt_version
+    )
+  endif
 endif
 config_h.set('HAVE_GCRYPT', enable_gcrypt)
 


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