[gdk-pixbuf/meson-cleanups: 1/3] build: Clean up search for libpng
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdk-pixbuf/meson-cleanups: 1/3] build: Clean up search for libpng
- Date: Mon, 21 Mar 2022 08:49:16 +0000 (UTC)
commit 197f5b52251239b1ce424c72e2a4e4a7410c15d1
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Mon Mar 21 16:34:08 2022 +0800
build: Clean up search for libpng
We can use CMake's built-in search for the libpng headers and libraries
for Visual Studio-like compilers; however, we must use 'png' instead of
'libpng' for the package name for this to work.
This will cover the manual headers and .lib search in a more
comprehensive way, which CMake will handle for us and it is an
optionally-installed item for Visual Studio 2017 and later, and is very
commonly used on Windows dev environments.
Also use a common variable to indicate whether we are using an MSVC-like
compiler, to save future typing.
meson.build | 25 ++-----------------------
1 file changed, 2 insertions(+), 23 deletions(-)
---
diff --git a/meson.build b/meson.build
index aab4017ca..80b699a8f 100644
--- a/meson.build
+++ b/meson.build
@@ -249,35 +249,14 @@ elif builtin_loaders.contains('none')
builtin_loaders = []
endif
+is_msvc_like = cc.get_argument_syntax() == 'msvc'
# Loader dependencies
enabled_loaders = []
loaders_deps = []
png_opt = get_option('png')
if not png_opt.disabled()
- png_dep = dependency('libpng', required: false)
-
- if not png_dep.found() and cc.has_header('png.h')
- # MSVC: First look for the DLL + import .lib build of libpng,
- # which is normally libpngxx.lib, when libpng's pkg-config can't
- # be found, which is quite normal on MSVC.
- foreach png: [ 'libpng16', 'libpng15', 'libpng14', 'libpng12', 'libpng13', 'libpng10' ]
- png_dep = cc.find_library(png, required: false)
- if png_dep.found()
- break
- endif
- endforeach
-
- # If we still can't find libpng, try looking for the static libpng.lib,
- # which means we need to ensure we have the static zlib .lib as well
- if not png_dep.found()
- png_dep = cc.find_library('libpng', required: false)
- zlib_dep = cc.find_library('zlib', required: false)
- if png_dep.found() and zlib_dep.found()
- loaders_deps += zlib_dep
- endif
- endif
- endif
+ png_dep = dependency(is_msvc_like ? 'png' : 'libpng', required: false)
# Finally, look for the dependency in a fallback subproject if allowed by
# the --wrap-mode option. We don't directly call subproject() here because
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]