Skip to content

Commit

Permalink
Merge pull request #434 from micro-manager/meson-misc
Browse files Browse the repository at this point in the history
Misc fixes to MMDevice/MMCore Meson build files
  • Loading branch information
marktsuchida authored Jan 22, 2024
2 parents 6857bb2 + 127b0ff commit 6b3fc8f
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 4 deletions.
26 changes: 24 additions & 2 deletions 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 Expand Up @@ -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
],
Expand All @@ -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(),
]
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)
6 changes: 6 additions & 0 deletions MMDevice/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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()]
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 6b3fc8f

Please sign in to comment.