[gtk/master-msvc-fixes] meson: Improve search for libpng
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/master-msvc-fixes] meson: Improve search for libpng
- Date: Wed, 29 Sep 2021 03:53:30 +0000 (UTC)
commit aa2e304a7fcc47f978182bc1c09e355bbded6b46
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Wed Sep 29 11:50:06 2021 +0800
meson: Improve search for libpng
Unfortunately, the CMake build system on libpng do not create usable pkg-config
files or CMake config files for us for Visual Studio builds, so we need to look
harder by looking for libpng's headers and libraries, like what GDK-Pixbuf
does, before we use a subproject fallback.
This is not done for libtiff and libjpeg-turbo, as both of these projects use
CMake builds that do generate pkg-config files for us, at least as an option.
meson.build | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/meson.build b/meson.build
index e85daf88f5..e992d73708 100644
--- a/meson.build
+++ b/meson.build
@@ -400,9 +400,34 @@ pangocairo_dep = dependency('pangocairo', version: pango_req,
pixbuf_dep = dependency('gdk-pixbuf-2.0', version: gdk_pixbuf_req,
fallback : ['gdk-pixbuf', 'gdkpixbuf_dep'],
default_options: ['png=enabled', 'jpeg=enabled', 'builtin_loaders=png,jpeg',
'man=false'])
-png_dep = dependency('libpng',
- fallback: ['libpng', 'libpng_dep'],
- required: true)
+
+# Look for the libpng dependency via pkg-config/CMake first
+png_dep = dependency('libpng', required: false)
+
+# Next, look for the libpng DLL import .lib or static .lib on Visual
+# Studio-like compilers, if needed (which is quite normal). We don't
+# need to look for ZLib here since GIO will pull that in
+if not png_dep.found() and cc.get_argument_syntax() == 'msvc'
+ # versioned: DLL import .lib (follows order in GDK-Pixbuf)
+ # non-versioned: static .lib
+ foreach png_ver: [ '16', '15', '14', '12', '13', '10', '' ]
+ if not png_dep.found()
+ png_dep = cc.find_library(
+ 'libpng@0@'.format(png_ver),
+ has_headers: ['png.h'],
+ required: false
+ )
+ endif
+ endforeach
+endif
+
+# If libpng is not found, do fallback
+if not png_dep.found()
+ png_dep = dependency('libpng',
+ fallback: ['libpng', 'libpng_dep'],
+ required: true)
+endif
+
tiff_dep = dependency('libtiff-4',
fallback: ['libtiff', 'libtiff4_dep'],
required: true)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]