libgimbase, meson: reorganize execinfo dependency testing.

As discussed in !455: remove duplicate testing, testing header and
testing the library are a same test in one (for instance we don't want
to get into weird cases where the lib is found but not the header; this
updated test takes such inconsistencies into account). Also it's better
to have all dependency tests together in the root meson file.

Finally adding some comments to make this all more understandable for
anyone looking at this in the future.
This commit is contained in:
Jehan 2021-08-04 21:11:24 +02:00
parent 37593d6da3
commit 54263f254d
2 changed files with 10 additions and 4 deletions

View file

@ -100,13 +100,14 @@ libgimpbase_introspectable = [
libgimpbase_headers_introspectable,
]
optional_libexecinfo = cc.find_library('execinfo', required: false)
libgimpbase = library('gimpbase-' + gimp_api_version,
libgimpbase_sources,
include_directories: rootInclude,
dependencies: [
gexiv2, gio, math, optional_libexecinfo
gexiv2, gio, math,
# optionally depend on libexecinfo on platforms where it is not
# internal to the libc.
opt_execinfo,
],
c_args: [
'-DG_LOG_DOMAIN="LibGimpBase"',

View file

@ -1214,7 +1214,6 @@ conf.set('HAVE_VPRINTF',
foreach header : [
{ 'm': 'HAVE_ALLOCA_H', 'v': 'alloca.h' },
{ 'm': 'HAVE_DLFCN_H', 'v': 'dlfcn.h' },
{ 'm': 'HAVE_EXECINFO_H', 'v': 'execinfo.h' },
{ 'm': 'HAVE_FCNTL_H', 'v': 'fcntl.h' },
{ 'm': 'HAVE_IEEEFP_H', 'v': 'ieeefp.h' },
{ 'm': 'HAVE_INTTYPES_H', 'v': 'inttypes.h' },
@ -1241,6 +1240,12 @@ foreach header : [
conf.set(header['m'], cc.has_header(header['v']) ? 1 : false)
endforeach
# In musl, backtrace() is in the libexecinfo library.
# In glibc, it is internal (there we only need the header).
# So we look for both cases, so that we are able to link to libexecinfo
# if it exists. Cf. !455.
opt_execinfo = cc.find_library('execinfo', has_headers: ['execinfo.h'], required: false)
conf.set('HAVE_EXECINFO_H', opt_execinfo.found() or cc.has_header('execinfo.h') ? 1 : false)
################################################################################