diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2021-04-30 16:27:01 -0400 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.com> | 2021-05-05 08:45:49 -0400 |
commit | 16fbd5e83b5506612c01f903c07b21e85ecad06e (patch) | |
tree | b65f88220667364d03704f54b790070247af188c /meson.build | |
parent | 9bdc005b8d6434f96beb6ae1f5c7962eb99ecbf1 (diff) | |
download | gdk-pixbuf-16fbd5e83b5506612c01f903c07b21e85ecad06e.tar.gz |
Meson: Small fixes to dependency lookup
- When png/jpeg/tiff option is set to true it should abort when
dependency cannot be found one way or another.
- Use libjpeg-turbo meson port instead of libjpeg from wrapdb to fix
build on Windows.
- Rely on libpng.pc instead of checking each individual version.
Fixes: #182
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 108 |
1 files changed, 43 insertions, 65 deletions
diff --git a/meson.build b/meson.build index 8328fcbc3..fde0e9ade 100644 --- a/meson.build +++ b/meson.build @@ -254,56 +254,40 @@ enabled_loaders = [] loaders_deps = [] if get_option('png') - # We have a vast selection of libpng versions to choose from - foreach png: [ 'libpng16', 'libpng15', 'libpng14', 'libpng13', 'libpng12', 'libpng10' ] - if not enabled_loaders.contains('png') - png_dep = dependency(png, required: false) + 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() - enabled_loaders += 'png' - loaders_deps += png_dep + break endif - endif - endforeach - - if not enabled_loaders.contains('png') - if cc.get_id() == 'msvc' 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' ] - if not enabled_loaders.contains('png') - png_dep = cc.find_library(png, required: false) - if png_dep.found() - enabled_loaders += 'png' - loaders_deps += png_dep - endif - 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 enabled_loaders.contains('png') - png_dep = cc.find_library('libpng', required: false) - zlib_dep = cc.find_library('zlib', required: false) - if png_dep.found() and zlib_dep.found() - enabled_loaders += 'png' - loaders_deps += [ png_dep, zlib_dep ] - endif - endif - endif + endforeach - # Finally, look for the dependency in a fallback subproject if allowed by - # the --wrap-mode option. We don't directly call subproject() here because - # that will bypass --wrap-mode and cause issues for distro packagers. - # See: https://mesonbuild.com/Reference-manual.html#dependency + # 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 = dependency('', required: false, fallback: ['libpng', 'png_dep']) - if png_dep.found() - enabled_loaders += 'png' - loaders_deps += png_dep + 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 + + # Finally, look for the dependency in a fallback subproject if allowed by + # the --wrap-mode option. We don't directly call subproject() here because + # that will bypass --wrap-mode and cause issues for distro packagers. + # See: https://mesonbuild.com/Reference-manual.html#dependency + if not png_dep.found() + png_dep = dependency('libpng', fallback: ['libpng', 'png_dep']) + endif + + enabled_loaders += 'png' + loaders_deps += png_dep endif # On Windows, check whether we are building the native Windows loaders @@ -335,28 +319,24 @@ if get_option('jpeg') and not native_windows_loaders endif endif - # If we couldn't find libjpeg in our include/linker paths, - # then use pkg-config, and if that fails, fall back to the - # wrap + # Finally, look for the dependency in a fallback if not jpeg_dep.found() - jpeg_dep = dependency('libjpeg', required: false, fallback: ['libjpeg', 'jpeg_dep']) + jpeg_dep = dependency('libjpeg', fallback: ['libjpeg-turbo', 'jpeg_dep']) endif - if jpeg_dep.found() - enabled_loaders += 'jpeg' - loaders_deps += jpeg_dep + enabled_loaders += 'jpeg' + loaders_deps += jpeg_dep - if jpeg_dep.type_name() == 'internal' - has_destroy_decompress = true - has_simple_progression = true - else - has_destroy_decompress = cc.has_function('jpeg_destroy_decompress', dependencies: jpeg_dep) - has_simple_progression = cc.has_function('jpeg_simple_progression', dependencies: jpeg_dep) - endif + if jpeg_dep.type_name() == 'internal' + has_destroy_decompress = true + has_simple_progression = true + else + has_destroy_decompress = cc.has_function('jpeg_destroy_decompress', dependencies: jpeg_dep) + has_simple_progression = cc.has_function('jpeg_simple_progression', dependencies: jpeg_dep) + endif - if has_destroy_decompress and has_simple_progression - gdk_pixbuf_conf.set('HAVE_PROGRESSIVE_JPEG', has_simple_progression) - endif + if has_destroy_decompress and has_simple_progression + gdk_pixbuf_conf.set('HAVE_PROGRESSIVE_JPEG', has_simple_progression) endif endif @@ -372,14 +352,12 @@ if get_option('tiff') and not native_windows_loaders if not tiff_dep.found() # For the static lib, zlib and libjpeg .lib's have been looked for first, and # they are optional for libtiff - tiff_dep = cc.find_library('libtiff', required: false) + tiff_dep = cc.find_library('libtiff') endif endif endif - if tiff_dep.found() - enabled_loaders += 'tiff' - loaders_deps += tiff_dep - endif + enabled_loaders += 'tiff' + loaders_deps += tiff_dep endif # Determine whether we enable application bundle relocation support, and we use |