[glib-networking] Fix openssl detection when there is no pkg-config file



commit 6ea390c599719679018f19bfc96fc8d8ce0557e6
Author: Xavier Claessens <xavier claessens collabora com>
Date:   Tue Jun 4 11:28:07 2019 -0400

    Fix openssl detection when there is no pkg-config file
    
    Many SDK ship openssl headers and library without the .pc file, not only
    on Windows. In that case we also need to fallback to find
    the library and its headers.
    
    Simplify the check for header files by using new syntax from Meson
    0.50.0 that can search for a library and a set of headers in one call.
    
    Fix find_library() calls by removing the 'lib' prefix, because Meson
    already prepend it automatically, so it was searching for
    bogus 'liblibcrypto.so'.

 meson.build | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)
---
diff --git a/meson.build b/meson.build
index 10141dc..68a579d 100644
--- a/meson.build
+++ b/meson.build
@@ -2,7 +2,7 @@ project(
   'glib-networking', 'c',
   version: '2.60.2',
   license: 'LGPL2.1+',
-  meson_version: '>= 0.47.0',
+  meson_version: '>= 0.50.0',
   default_options: ['c_std=c11']
 )
 
@@ -83,44 +83,38 @@ if openssl_option.disabled()
   openssl_dep = []
 else
   # XXX: https://github.com/mesonbuild/meson/issues/2945
-  openssl_dep = dependency('openssl', required: openssl_option.enabled() and cc.get_id() != 'msvc')
+  openssl_dep = dependency('openssl', required: false)
   if openssl_dep.found()
     backends += ['openssl']
-  elif cc.get_id() == 'msvc' and not openssl_option.disabled()
+  else
     # 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
-    have_openssl = true
+    openssl_headers = []
     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
+      openssl_headers += 'openssl/' + h
     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)
+    libcrypto_dep = cc.find_library('crypto', required: false)
     if libcrypto_dep.found()
-      libssl = 'libssl'
+      libssl = 'ssl'
     else
-      libcrypto_dep = cc.find_library('libeay32', required: openssl_option)
+      libcrypto_dep = cc.find_library('eay32', required: openssl_option)
       libssl = 'ssleay32'
     endif
 
     if libcrypto_dep.found()
       # Find the corresponding SSL library depending on which crypto .lib we found
-      libssl_dep = cc.find_library(libssl, required: openssl_option)
+      libssl_dep = cc.find_library(libssl, required: openssl_option, has_headers: openssl_headers)
     endif
 
-    if libcrypto_dep.found() and have_openssl
+    if libcrypto_dep.found() and libssl_dep.found()
       openssl_dep = [libcrypto_dep, libssl_dep]
       backends += ['openssl']
     endif


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