From 61cbb95c63566a9c378b0bb33c81145131ac23f8 Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 17 Aug 2021 17:27:36 +0200 Subject: [PATCH] [meson] Change Zlib configuration option. * meson_options.txt, meson.build: Change the format of the 'zlib' meson build configuration option to be a combo with the following choices: - none: Do not support gzip-compressed streams at all. - internal: Support gzip-compressed streams using the copy of the gzip sources under src/gzip/, this should only be used during development to ensure these work properly. - external: Support gzip-compressed streams using the 'zlib' Meson subproject, linked as a static library. - system: Support gzip-compressed streams using a system installed version of zlib. - auto: Support gzip-compressed streams using a system installed version of zlib, if available, or using the 'zlib' subproject otherwise. This is the default! - disabled: backward-compatible alias for 'none'. - enabled: backward-compatible alias for 'auto'. --- meson.build | 46 +++++++++++++++++++++++++++++++++++++++------- meson_options.txt | 4 ++-- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/meson.build b/meson.build index 5efb33d10..67fc2057e 100644 --- a/meson.build +++ b/meson.build @@ -246,15 +246,47 @@ ftoption_command = process_header_command # external GZip support -zlib_dep = dependency('zlib', - required: get_option('zlib'), - fallback: 'zlib') +zlib_option = get_option('zlib') -if zlib_dep.found() - ftoption_command += ['--enable=FT_CONFIG_OPTION_SYSTEM_ZLIB'] +# Backwards-compatible aliases. +if zlib_option == 'disabled' + zlib_option = 'none' +elif zlib_option == 'enabled' + zlib_option = 'auto' +endif + +if zlib_option == 'auto' + # First try to find a system installation, otherwise + # fallback to the subproject. + zlib_dep = dependency('zlib', required: false) + if zlib_dep.found() + zlib_option = 'system' + else + zlib_option = 'external' + endif +endif + +if zlib_option == 'none' + ftoption_command += [ '--disable=FT_CONFIG_OPTION_USE_ZLIB' ] +elif zlib_option == 'internal' + ftoption_command += [ '--enable=FT_CONFIG_OPTION_USE_ZLIB' ] +elif zlib_option == 'external' + ftoption_command += [ '--enable=FT_CONFIG_OPTION_USE_ZLIB' ] + zlib_project = subproject('zlib', + required: true, + default_options: 'default_library=static') + zlib_dep = zlib_project.get_variable('zlib_dep') + ft2_deps += [zlib_dep] +elif zlib_option == 'system' + zlib_dep = dependency('zlib', required: true) + assert(zlib_dep.found(), 'Could not find system zlib installation!') + ftoption_command += [ + '--enable=FT_CONFIG_OPTION_USE_ZLIB', + '--enable=FT_CONFIG_OPTION_SYSTEM_ZLIB', + ] ft2_deps += [zlib_dep] else - ftoption_command += ['--disable=FT_CONFIG_OPTION_SYSTEM_ZLIB'] + assert(false, 'Invalid zlib option ' + zlib_option) endif # BZip2 support @@ -400,7 +432,7 @@ gen_docs = custom_target('freetype2 reference documentation', summary({'OS': host_machine.system(), }, section: 'Operating System') -summary({'Zlib': zlib_dep.found() ? 'external' : 'internal', +summary({'Zlib': zlib_option, 'Bzip2': bzip2_dep.found() ? 'yes' : 'no', 'Png': libpng_dep.found() ? 'yes' : 'no', 'Harfbuzz': harfbuzz_dep.found() ? 'yes' : 'no', diff --git a/meson_options.txt b/meson_options.txt index 375eb714e..7f2879a68 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -46,8 +46,8 @@ option('tests', description: 'Enable FreeType unit and regression tests') option('zlib', - type: 'feature', - value: 'auto', + type: 'combo', + choices: ['auto', 'none', 'internal', 'external', 'system', 'disabled', 'enabled'], description: 'Support reading gzip-compressed font files') # EOF