diff --git a/MMCore/meson.build b/MMCore/meson.build index a24403066..3049fbb65 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( @@ -85,7 +99,10 @@ mmcore_lib = static_library( 'MMCore', sources: mmcore_sources, include_directories: mmcore_include_dir, - dependencies: mmdevice_dep, + dependencies: [ + mmdevice_dep, + dependency('threads'), + ], cpp_args: [ '-D_CRT_SECURE_NO_WARNINGS', # TODO Eliminate the need ], @@ -98,3 +115,8 @@ mmcore = declare_dependency( link_with: mmcore_lib, dependencies: mmdevice_dep, ) + +# For providing include dir to SWIG when using this project as a subproject +swig_include_dirs = mmdevice_proj.get_variable('swig_include_dirs') + [ + meson.current_source_dir(), +] 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.build b/MMDevice/meson.build index 9f6bdf496..dcddc8cb0 100644 --- a/MMDevice/meson.build +++ b/MMDevice/meson.build @@ -50,6 +50,9 @@ mmdevice_lib = static_library( # MMDevice does not depend on any external library. This is a big advantage # in simplifing its usage (given hundreds of device adapters depending on # MMDevice), so think twice before adding dependencies. + dependencies: [ + dependency('threads'), + ], ) subdir('unittest') @@ -58,3 +61,6 @@ mmdevice = declare_dependency( include_directories: mmdevice_include_dir, link_with: mmdevice_lib, ) + +# For providing include dir to SWIG when using this project as a subproject +swig_include_dirs = [meson.current_source_dir()] 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 +)