From fa803c7ecd0d45013dcc2a27d44b028266a08d24 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 17 Aug 2022 11:05:55 -0700 Subject: [PATCH] meson: use a feature option for tests instead of boolean This allows tests to be autodetected gracefully, which is particularly convenient for kyua and atf_sh which are fairly painful to build and install by hand. Those who want to ensure tests are enabled or disabled may pass `-Dtests=enabled` or `-Dtests=disabled` respectively. This does require a modest bump in the required meson version to 0.49, which was released at the end of 2018, so roughly 4 years ago. --- meson.build | 15 +++++++-------- meson_options.txt | 8 +++++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/meson.build b/meson.build index 25a46a8..0d42d42 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project('pkgconf', 'c', version : '1.9.3', license : 'ISC', - meson_version : '>=0.47', + meson_version : '>=0.49', default_options : ['c_std=c99'], ) @@ -117,13 +117,12 @@ pkgconf_exe = executable('pkgconf', c_args: build_static, install : true) -if get_option('tests') - kyua_exe = find_program('kyua') - atf_sh_exe = find_program('atf-sh') - kyuafile = configure_file(input : 'Kyuafile.in', output : 'Kyuafile', configuration : cdata) - test('kyua', kyua_exe, args : ['--config=none', 'test', '--kyuafile', kyuafile, '--build-root', meson.current_build_dir()]) - subdir('tests') -endif +with_tests = get_option('tests') +kyua_exe = find_program('kyua', required : with_tests, disabler : true) +atf_sh_exe = find_program('atf-sh', required : with_tests, disabler : true) +kyuafile = configure_file(input : 'Kyuafile.in', output : 'Kyuafile', configuration : cdata) +test('kyua', kyua_exe, args : ['--config=none', 'test', '--kyuafile', kyuafile, '--build-root', meson.current_build_dir()]) +subdir('tests') install_man('man/pkgconf.1') install_man('man/pkg.m4.7') diff --git a/meson_options.txt b/meson_options.txt index d1d0000..c61926f 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,3 +1,5 @@ -option('tests', type: 'boolean', value: true, - description: 'Build tests which depends upon the kyua framework' -) \ No newline at end of file +option( + 'tests', + type: 'feature', + description: 'Build tests which depends upon the kyua framework', +)