[gimp/wip/Jehan/meson-windows-official: 12/14] meson, plug-ins: further fix the no-pkg-config test for libmng.




commit 49732c2d4dca08cdfa690d9b093eb86daac39679
Author: Jehan <jehan girinstud io>
Date:   Thu Mar 31 18:27:23 2022 +0200

    meson, plug-ins: further fix the no-pkg-config test for libmng.
    
    As suggested by jeremyd2019 and Biswa96 of MSYS2 project, defining the
    MNG_USE_DLL macro would trigger libmng header code to fix the calling
    convention. This way, even the old detection code now works with Windows
    32-bit.
    
    The reason why we still stick to this old detection code is that the
    pkg-config is likely not everywhere (e.g. in Debian package libmng-dev,
    there is no `.pc` file). So the pkg-config test is good but we still
    definitely need to keep our fallback more old-school test for this
    dependency.
    
    See this comment in particular:
    https://github.com/msys2/MINGW-packages/issues/11136#issuecomment-1084627263
    
    Note: I am unsure yet how to apply the same trick on the autotools test
    because AC_CHECK_LIB() would allow us to tweak the cflags to define a
    macro, but we also need to include libmng.h header, otherwise the
    calling convention tweak is not run. It doesn't look to be feasible with
    the autoconf macro, or at least I haven't found how yet.

 meson.build                 | 10 ++++++++--
 plug-ins/common/meson.build |  7 ++++++-
 2 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/meson.build b/meson.build
index 0227e9524e..cfa9e368bd 100644
--- a/meson.build
+++ b/meson.build
@@ -661,8 +661,14 @@ MIMEtypes += [ 'image/png', 'image/x-icon']
 libmng = dependency('libmng', required: get_option('mng'))
 
 if not libmng.found()
-  libmng = cc.find_library('mng', required: get_option('mng'))
-  if libmng.found() and not cc.has_function('mng_create', dependencies: libmng)
+  libmng = cc.find_library('mng', required: get_option('mng'),)
+
+  mng_test_prefix = ''
+  if platform_windows
+    mng_test_prefix = '#define MNG_USE_DLL\n#include <libmng.h>'
+  endif
+  if libmng.found() and not cc.has_function('mng_create', dependencies: libmng,
+                                            prefix: mng_test_prefix)
     libmng = no_dep
   endif
 endif
diff --git a/plug-ins/common/meson.build b/plug-ins/common/meson.build
index 98153b260b..8a8f17bc5c 100644
--- a/plug-ins/common/meson.build
+++ b/plug-ins/common/meson.build
@@ -111,8 +111,13 @@ if libjxl.found() and libjxl_threads.found()
 endif
 
 if libmng.found()
+  mng_cflags = []
+  if platform_windows
+    mng_cflags = [ '-DMNG_USE_DLL' ]
+  endif
   common_plugins_list += { 'name': 'file-mng',
-    'deps': [ gtk3, gegl, libmng, libpng, ],
+                           'deps': [ gtk3, gegl, libmng, libpng, ],
+                           'cflags': mng_cflags,
   }
 endif
 


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