Skip to content

Commit

Permalink
Merge pull request #45 from Guldoman/PR_meson_arch_mbedtls2
Browse files Browse the repository at this point in the history
Improve `mbedtls2` detection in meson
  • Loading branch information
adamharrison authored Oct 2, 2023
2 parents 1a54a85 + 2d58caf commit d6650d1
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,29 @@ project('lpm',
cc = meson.get_compiler('c')

zlib_dep = dependency('zlib')
mbedtls_dep = dependency('mbedtls', required: false)
mbedtls_dep = dependency('mbedtls', version: '<3', required: false)
libgit2_dep = dependency('libgit2')
libzip_dep = dependency('libzip')
lua_dep = dependency('lua')
microtar_dep = dependency('microtar', required: false)

if not mbedtls_dep.found()
mbedtls_dep = [
cc.find_library('mbedtls'),
cc.find_library('mbedx509'),
cc.find_library('mbedcrypto'),
]
# Using has_headers to distinguish between mbedtls2 and mbedtls3
_mbedtls_dep = cc.find_library('mbedtls', has_headers: 'mbedtls/net.h', required: false)
if _mbedtls_dep.found()
mbedtls_dep = [
_mbedtls_dep,
cc.find_library('mbedx509'),
cc.find_library('mbedcrypto'),
]
else
# In some cases we need to manually specify where to find mbedtls2
message('Using fallback mbedtls definition')
mbedtls_dep = declare_dependency(
include_directories: ['/usr/include/mbedtls2/'],
link_args: ['-L/usr/lib/mbedtls2', '-lmbedtls', '-lmbedx509', '-lmbedcrypto']
)
endif
endif

if not microtar_dep.found()
Expand Down

0 comments on commit d6650d1

Please sign in to comment.