summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2022-03-21 16:34:08 +0800
committerChun-wei Fan <fanchunwei@src.gnome.org>2022-03-21 16:38:45 +0800
commit197f5b52251239b1ce424c72e2a4e4a7410c15d1 (patch)
treeb87409fb9367b8804b8012bf88df712395c07cb1
parent9b7308cbb21e916fb1e6e682b2e1a3d7a75c48ea (diff)
downloadgdk-pixbuf-197f5b52251239b1ce424c72e2a4e4a7410c15d1.tar.gz
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.
-rw-r--r--meson.build25
1 files 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