Commit 6ea390c5 authored by Xavier Claessens's avatar Xavier Claessens

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 ''.
parent 7c634d0d
Pipeline #86346 passed with stage
in 1 minute and 52 seconds
......@@ -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 = []
# XXX:
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()
# 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))
openssl_headers += 'openssl/' + h
# 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'
libcrypto_dep = cc.find_library('libeay32', required: openssl_option)
libcrypto_dep = cc.find_library('eay32', required: openssl_option)
libssl = 'ssleay32'
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)
if libcrypto_dep.found() and have_openssl
if libcrypto_dep.found() and libssl_dep.found()
openssl_dep = [libcrypto_dep, libssl_dep]
backends += ['openssl']
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment