meson: Simplify finding OpenSSL 44/271244/1
authorOlivier CrĂȘte <olivier.crete@collabora.com>
Tue, 2 Nov 2021 17:14:55 +0000 (13:14 -0400)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 17 Feb 2022 05:18:24 +0000 (14:18 +0900)
Remove duplicated calls to dependency() so we can have fallback in all
cases.

Change-Id: Ic278734a9824e1646aec50a1d807b0451f8bf834

meson.build

index 48b69ac..07a6cc1 100644 (file)
@@ -190,21 +190,21 @@ gthread_dep = dependency('gthread-2.0',
 # Cryto library
 opt_cryptolib = get_option('crypto-library')
 message('Crypto library requested: ' + opt_cryptolib)
-if opt_cryptolib != 'openssl'
+crypto_dep = dependency('', required: false) # special always not found
+if opt_cryptolib == 'auto' and host_machine.system() == 'windows'
+  crypto_dep = cc.find_library('advapi32')
+  cdata.set('USE_WIN32_CRYPTO', crypto_dep.found())
+endif
+
+if not crypto_dep.found() and opt_cryptolib != 'openssl'
   crypto_dep = dependency('gnutls', version: gnutls_req, required: false)
   cdata.set('HAVE_GNUTLS', crypto_dep.found())
-  if not crypto_dep.found() and opt_cryptolib == 'auto'
-    crypto_dep = dependency('openssl', required: false,
-      fallback: ['openssl', 'openssl_dep'])
-    cdata.set('HAVE_OPENSSL', crypto_dep.found())
-  endif
-else
-  crypto_dep = dependency('openssl', required: false)
+endif
+
+if not crypto_dep.found() and opt_cryptolib != 'gnutls'
+  crypto_dep = dependency('openssl', required: false,
+                         fallback: ['openssl', 'openssl_dep'])
   cdata.set('HAVE_OPENSSL', crypto_dep.found())
-  if not crypto_dep.found() and opt_cryptolib == 'auto'
-    crypto_dep = dependency('gnutls', version: gnutls_req, required: false)
-    cdata.set('HAVE_GNUTLS', crypto_dep.found())
-  endif
 endif
 
 crypto_found = crypto_dep.found()
@@ -238,6 +238,7 @@ if not crypto_found and opt_cryptolib != 'gnutls'
 
   if libcrypto_dep.found() and libssl_dep.found()
     crypto_dep = [libcrypto_dep, libssl_dep]
+    cdata.set('HAVE_OPENSSL', crypto_dep.found())
     crypto_found = true
   endif
 endif