[gimp] libgimbase, meson: reorganize execinfo dependency testing.



commit 54263f254dd1e4024fd054b17d2ecf3b64cf4391
Author: Jehan <jehan girinstud io>
Date:   Wed Aug 4 21:11:24 2021 +0200

    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.

 libgimpbase/meson.build | 7 ++++---
 meson.build             | 7 ++++++-
 2 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/libgimpbase/meson.build b/libgimpbase/meson.build
index b1c6d9c7eb..b5de0ac1d9 100644
--- a/libgimpbase/meson.build
+++ b/libgimpbase/meson.build
@@ -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"',
diff --git a/meson.build b/meson.build
index f933f1533e..2f84503893 100644
--- a/meson.build
+++ b/meson.build
@@ -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)
 
 
 ################################################################################


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