[glib-networking] meson: Fix searching for openssl on MSVC



commit c5b91f1fd4bc58e10f0b63766b141d5188331303
Author: Nirbheek Chauhan <nirbheek centricular com>
Date:   Wed Feb 20 19:53:28 2019 +0530

    meson: Fix searching for openssl on MSVC
    
    cc.has_header() is not fatal so we were not actually checking anything
    
    If required: is not specified, dependency() is fatal, which meant that
    it was impossible to build without openssl on MSVC.

 meson.build | 46 +++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)
---
diff --git a/meson.build b/meson.build
index b15a0be..f0697e9 100644
--- a/meson.build
+++ b/meson.build
@@ -84,48 +84,48 @@ if gnutls_dep.found()
 endif
 
 # *** Checks for OpenSSL    ***
-openssl_dep = dependency('openssl', required: get_option('openssl'))
+openssl_option = get_option('openssl')
+openssl_dep = dependency('openssl', required: openssl_option)
 if openssl_dep.found()
   backends += ['openssl']
-elif cc.get_id() == 'msvc'
+elif cc.get_id() == 'msvc' and not openssl_option.disabled()
   # MSVC builds of OpenSSL does not generate pkg-config files,
   # so we check for it manually here in this case, if we can't find those files
   # Based on the CMake check for OpenSSL in CURL's CMakeLists.txt,
   # on which headers we should check for
-  cc.has_header('openssl/crypto.h')
-  cc.has_header('openssl/engine.h')
-  cc.has_header('openssl/err.h')
-  cc.has_header('openssl/pem.h')
-  cc.has_header('openssl/rsa.h')
-  cc.has_header('openssl/ssl.h')
-  cc.has_header('openssl/x509.h')
-  cc.has_header('openssl/rand.h')
-  cc.has_header('openssl/tls1.h')
+  have_openssl = true
+  foreach h : ['crypto.h', 'engine.h', 'err.h', 'pem.h',
+               'rsa.h', 'ssl.h', 'x509.h', 'rand.h', 'tls1.h']
+    header = 'openssl/' + h
+    if not cc.has_header(header)
+      have_openssl = false
+      if openssl_option.enabled()
+        error('openssl module is enabled and @0@ not found'.format(header))
+      endif
+    endif
+  endforeach
 
   # OpenSSL 1.1.x and 1.0.x (or earlier) have different .lib names,
   # so we need to look for the correct pair
 
   # Find either libcrypto.lib (1.1.x) or libeay32.lib (1.0.x or earlier) first
   libcrypto_dep = cc.find_library('libcrypto', required: false)
-  if not libcrypto_dep.found()
-    libeay_dep = cc.find_library('libeay32')
+  if libcrypto_dep.found()
+    libssl = 'libssl'
+  else
+    libcrypto_dep = cc.find_library('libeay32', required: openssl_option)
+    libssl = 'ssleay32'
   endif
 
-  # Find the corresponding SSL library depending on which crypto .lib we found
   if libcrypto_dep.found()
-    libssl_dep = cc.find_library('libssl')
-  elif libeay_dep.found()
-    ssleay_dep = cc.find_library('ssleay32')
+    # Find the corresponding SSL library depending on which crypto .lib we found
+    libssl_dep = cc.find_library(libssl, required: openssl_option)
   endif
 
-  # Now set the openssl dependency to the corresponding pair of .lib files that we found
-  if libcrypto_dep.found()
+  if libcrypto_dep.found() and have_openssl
     openssl_dep = [libcrypto_dep, libssl_dep]
-  else
-    openssl_dep = [libeay_dep, ssleay_dep]
+    backends += ['openssl']
   endif
-
-  backends += ['openssl']
 endif
 
 if backends.length() == 0


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