Skip to content

Commit

Permalink
MMDevice/MMCore: Make Meson build tests optional
Browse files Browse the repository at this point in the history
  • Loading branch information
marktsuchida committed Jan 22, 2024
1 parent d5ea2cf commit 678a490
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
16 changes: 15 additions & 1 deletion MMCore/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions MMCore/meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
option('tests', type: 'feature', value: 'enabled',
description: 'Build unit tests',
)
4 changes: 3 additions & 1 deletion MMCore/unittest/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -28,4 +30,4 @@ mmcore_test_exe = executable(
],
)

test('MMCore tests', mmcore_test_exe)
test('MMCore tests', mmcore_test_exe)
3 changes: 3 additions & 0 deletions MMDevice/meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
option('tests', type: 'feature', value: 'enabled', yield: true,
description: 'Build unit tests',
)
4 changes: 3 additions & 1 deletion MMDevice/unittest/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -23,4 +25,4 @@ mmdevice_test_exe = executable(
test(
'MMDevice unit tests',
mmdevice_test_exe,
)
)

0 comments on commit 678a490

Please sign in to comment.