https://github.com/yhirose/cpp-httplib/pull/2350 Add support for mbedtls to meson --- a/meson.build +++ b/meson.build @@ -39,11 +39,29 @@ endif deps = [dependency('threads')] args = [] -openssl_dep = dependency('openssl', version: '>=3.0.0', required: get_option('openssl')) -if openssl_dep.found() - deps += openssl_dep - args += '-DCPPHTTPLIB_OPENSSL_SUPPORT' - if host_machine.system() == 'darwin' +if get_option('ssl').allowed() + ssl_found = false + if get_option('ssl_backend') == 'openssl' + openssl_dep = dependency('openssl', version: '>=3.0.0', required: get_option('ssl')) + if openssl_dep.found() + deps += openssl_dep + args += '-DCPPHTTPLIB_OPENSSL_SUPPORT' + ssl_found = true + endif + else + mbedtls_dep = dependency('mbedtls', required: get_option('ssl')) + mbedtlsx509_dep = dependency('mbedx509', required: get_option('ssl')) + mbedtlscrypto_dep = dependency('mbedcrypto', required: get_option('ssl')) + if mbedtls_dep.found() and mbedtlsx509_dep.found() and mbedtlscrypto_dep.found() + deps += mbedtls_dep + deps += mbedtlsx509_dep + deps += mbedtlscrypto_dep + args += '-DCPPHTTPLIB_MBEDTLS_SUPPORT' + ssl_found = true + endif + endif + + if ssl_found and host_machine.system() == 'darwin' macosx_keychain_dep = dependency('appleframeworks', modules: ['CFNetwork', 'CoreFoundation', 'Security'], required: get_option('macosx_keychain')) if macosx_keychain_dep.found() deps += macosx_keychain_dep --- a/meson_options.txt +++ b/meson_options.txt @@ -2,7 +2,8 @@ # # SPDX-License-Identifier: MIT -option('openssl', type: 'feature', value: 'auto', description: 'Enable OpenSSL support') +option('ssl', type: 'feature', description: 'Enable SSL support') +option('ssl_backend', type: 'combo', choices: ['openssl', 'mbedtls'], value: 'openssl', description: 'Which SSL library to use') option('zlib', type: 'feature', value: 'auto', description: 'Enable zlib support') option('brotli', type: 'feature', value: 'auto', description: 'Enable Brotli support') option('zstd', type: 'feature', value: 'auto', description: 'Enable zstd support') @@ -12,6 +13,7 @@ option('compile', type: 'boolean', value: false, description: 'Split the header option('test', type: 'boolean', value: false, description: 'Build tests') # Old option names +option('openssl', type: 'feature', deprecated: 'ssl') option('cpp-httplib_openssl', type: 'feature', deprecated: 'openssl') option('cpp-httplib_zlib', type: 'feature', deprecated: 'zlib') option('cpp-httplib_brotli', type: 'feature', deprecated: 'brotli')