From 678a4903cd9fd61c0d8f813b4a695183dde2c763 Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Mon, 22 Jan 2024 17:41:28 -0600 Subject: [PATCH] MMDevice/MMCore: Make Meson build tests optional --- MMCore/meson.build | 16 +++++++++++++++- MMCore/meson_options.txt | 3 +++ MMCore/unittest/meson.build | 4 +++- MMDevice/meson_options.txt | 3 +++ MMDevice/unittest/meson.build | 4 +++- 5 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 MMCore/meson_options.txt create mode 100644 MMDevice/meson_options.txt diff --git a/MMCore/meson.build b/MMCore/meson.build index fd9fbcecc..0373d739a 100644 --- a/MMCore/meson.build +++ b/MMCore/meson.build @@ -19,7 +19,21 @@ endif # MMDevice must be copied into subprojects/ for this experimental build to work # (unless MMCore is itself being used as a subproject). -mmdevice_proj = subproject('MMDevice') +if get_option('tests').enabled() + tests_option = 'enabled' +elif get_option('tests').disabled() + tests_option = 'disabled' +else + tests_option = 'auto' +endif +mmdevice_proj = subproject( + 'MMDevice', + # Propagate value of 'tests' option ('yield: true' in MMDeivce's 'tests' + # option did not seem to work; Meson 1.3.1). + default_options: { + 'tests': tests_option, + }, +) mmdevice_dep = mmdevice_proj.get_variable('mmdevice') mmcore_sources = files( diff --git a/MMCore/meson_options.txt b/MMCore/meson_options.txt new file mode 100644 index 000000000..e9af6fe9a --- /dev/null +++ b/MMCore/meson_options.txt @@ -0,0 +1,3 @@ +option('tests', type: 'feature', value: 'enabled', + description: 'Build unit tests', +) diff --git a/MMCore/unittest/meson.build b/MMCore/unittest/meson.build index 416d51109..67feffc25 100644 --- a/MMCore/unittest/meson.build +++ b/MMCore/unittest/meson.build @@ -5,6 +5,8 @@ catch2_with_main_dep = dependency( 'catch2-with-main', allow_fallback: true, include_type: 'system', + required: get_option('tests'), + disabler: true, ) mmcore_test_sources = files( @@ -28,4 +30,4 @@ mmcore_test_exe = executable( ], ) -test('MMCore tests', mmcore_test_exe) \ No newline at end of file +test('MMCore tests', mmcore_test_exe) diff --git a/MMDevice/meson_options.txt b/MMDevice/meson_options.txt new file mode 100644 index 000000000..4f5d777ee --- /dev/null +++ b/MMDevice/meson_options.txt @@ -0,0 +1,3 @@ +option('tests', type: 'feature', value: 'enabled', yield: true, + description: 'Build unit tests', +) diff --git a/MMDevice/unittest/meson.build b/MMDevice/unittest/meson.build index 7c4f77276..dbca08cff 100644 --- a/MMDevice/unittest/meson.build +++ b/MMDevice/unittest/meson.build @@ -5,6 +5,8 @@ catch2_with_main_dep = dependency( 'catch2-with-main', allow_fallback: true, include_type: 'system', + required: get_option('tests'), + disabler: true, ) mmdevice_test_sources = files( @@ -23,4 +25,4 @@ mmdevice_test_exe = executable( test( 'MMDevice unit tests', mmdevice_test_exe, -) \ No newline at end of file +)