From 56792a28215d732e8a1940af10071e49cd4857b0 Mon Sep 17 00:00:00 2001 From: bbhtt Date: Tue, 14 Jan 2025 07:37:47 +0530 Subject: [PATCH] meson: Allow tests to be optional --- meson.build | 8 +++++++- meson_options.txt | 10 ++++++++++ tests/meson.build | 4 +++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 9baa4e2da..5b1ccae88 100644 --- a/meson.build +++ b/meson.build @@ -204,6 +204,10 @@ if get_option('stemming') endif endif +if get_option('installed_tests') and not get_option('tests') + error('-Dinstalled_tests=true is incompatible with -Dtests=false') +endif + # use gperf for faster string -> enum matching gperf = find_program('gperf') @@ -227,7 +231,9 @@ subdir('po/') subdir('data/') subdir('contrib/') subdir('docs/') -subdir('tests/') +if get_option('tests') + subdir('tests/') +endif if get_option('qt') subdir('qt/') endif diff --git a/meson_options.txt b/meson_options.txt index 6964e47aa..a37a1e73d 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -65,6 +65,16 @@ option('install-docs', value : true, description : 'Install documentation for API and specification' ) +option('tests', + description: 'Build the test suite', + type: 'boolean', + value: true +) +option('installed_tests', + description: 'Install the test suite', + type: 'boolean', + value: true +) # # For development diff --git a/tests/meson.build b/tests/meson.build index f17104554..821f3d917 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,6 +1,8 @@ # Meson definition for AppStream Tests -subdir('installed-tests/') +if get_option('installed_tests') + subdir('installed-tests/') +endif as_test_env = [] as_test_args = [meson.current_source_dir()]