Skip to content

Commit

Permalink
Experimental Meson build for MMDevice, MMCore
Browse files Browse the repository at this point in the history
MMDevice builds on its own.

MMCore requires a copy (or symlink) of MMDevice to be in its
subprojects/ directory. (This is unavoidable as we develop the Meson
build in place. When MMDevice and MMCore are in their own repositories
(and/or have source tarballs) MMCore will be able to depend on MMDevice
as either a git submodule or a Meson wrap.)
  • Loading branch information
marktsuchida committed Dec 14, 2023
1 parent ac1035c commit 8c02aaa
Show file tree
Hide file tree
Showing 8 changed files with 301 additions and 0 deletions.
98 changes: 98 additions & 0 deletions MMCore/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# This Meson script is experimental and potentially incomplete. It is not part
# of the supported build system for Micro-Manager or mmCoreAndDevices.

project(
'MMCore',
'cpp',
meson_version: '>=1.1.0', # May relax
default_options: [
'cpp_std=c++14',
'warning_level=3',
],
)

cxx = meson.get_compiler('cpp')

if cxx.get_id() in ['msvc', 'clang-cl']
add_project_arguments('-DNOMINMAX', language: 'cpp')
add_project_arguments('/wd4290', language: 'cpp')
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')
mmdevice_dep = mmdevice_proj.get_variable('mmdevice')

mmcore_sources = files(
'CircularBuffer.cpp',
'Configuration.cpp',
'CoreCallback.cpp',
'CoreFeatures.cpp',
'CoreProperty.cpp',
'DeviceManager.cpp',
'Devices/AutoFocusInstance.cpp',
'Devices/CameraInstance.cpp',
'Devices/DeviceInstance.cpp',
'Devices/GalvoInstance.cpp',
'Devices/HubInstance.cpp',
'Devices/ImageProcessorInstance.cpp',
'Devices/MagnifierInstance.cpp',
'Devices/SerialInstance.cpp',
'Devices/ShutterInstance.cpp',
'Devices/SignalIOInstance.cpp',
'Devices/SLMInstance.cpp',
'Devices/StageInstance.cpp',
'Devices/StateInstance.cpp',
'Devices/XYStageInstance.cpp',
'Error.cpp',
'FrameBuffer.cpp',
'LibraryInfo/LibraryPathsUnix.cpp',
'LibraryInfo/LibraryPathsWindows.cpp',
'LoadableModules/LoadedDeviceAdapter.cpp',
'LoadableModules/LoadedModule.cpp',
'LoadableModules/LoadedModuleImpl.cpp',
'LoadableModules/LoadedModuleImplUnix.cpp',
'LoadableModules/LoadedModuleImplWindows.cpp',
'Logging/Metadata.cpp',
'LogManager.cpp',
'MMCore.cpp',
'PluginManager.cpp',
'Semaphore.cpp',
'Task.cpp',
'TaskSet.cpp',
'TaskSet_CopyMemory.cpp',
'ThreadPool.cpp',
)

mmcore_include_dir = include_directories('.')

mmcore_public_headers = files(
'Configuration.h',
'Error.h',
'ErrorCodes.h',
'MMCore.h',
'MMEventCallback.h',
# TODO MMCore.h currently includes Logging/Logger.h and CoreUtils.h, which
# should not be public. That will need to be fixed before we support
# installing the public headers.
)

# TODO Allow MMCore to be built as a shared library, too. For that, we'd need
# to define the exported symbols on Windows (__declspec(dllexport)).
mmcore_lib = static_library(
'MMCore',
sources: mmcore_sources,
include_directories: mmcore_include_dir,
dependencies: mmdevice_dep,
cpp_args: [
'-D_CRT_SECURE_NO_WARNINGS', # TODO Eliminate the need
],
)

subdir('unittest')

mmcore = declare_dependency(
include_directories: mmcore_include_dir,
link_with: mmcore_lib,
dependencies: mmdevice_dep,
)
12 changes: 12 additions & 0 deletions MMCore/subprojects/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/packagecache/

/MMDevice/

# Subprojects installed by meson wrap
/*-*/

# Ignore *.wrap by default (may be auto-installed transitive dependencies)
/*.wrap

# Do not ignore wraps we provide
!/gtest.wrap
16 changes: 16 additions & 0 deletions MMCore/subprojects/gtest.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[wrap-file]
directory = googletest-1.14.0
source_url = https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz
source_filename = gtest-1.14.0.tar.gz
source_hash = 8ad598c73ad796e0d8280b082cebd82a630d73e73cd3c70057938a6501bba5d7
patch_filename = gtest_1.14.0-1_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/gtest_1.14.0-1/get_patch
patch_hash = 2e693c7d3f9370a7aa6dac802bada0874d3198ad4cfdf75647b818f691182b50
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/gtest_1.14.0-1/gtest-1.14.0.tar.gz
wrapdb_version = 1.14.0-1

[provide]
gtest = gtest_dep
gtest_main = gtest_main_dep
gmock = gmock_dep
gmock_main = gmock_main_dep
57 changes: 57 additions & 0 deletions MMCore/unittest/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This Meson script is experimental and potentially incomplete. It is not part
# of the supported build system for Micro-Manager or mmCoreAndDevices.

gtest_proj = subproject('gtest')
gtest_dep = gtest_proj.get_variable('gtest_dep')

# TODO: Use a single executable for all tests -- but that requires modifying
# the sources (to remove main()), so needs to wait until we remove these tests
# from the Automake build.

mmcore_apierror_test_exe = executable(
'MMCoreAPIErrorTest',
sources: 'APIError-Tests.cpp',
include_directories: mmcore_include_dir,
link_with: mmcore_lib,
dependencies: [
mmdevice_dep,
gtest_dep,
],
)

test('MMCore APIError test', mmcore_apierror_test_exe)

mmcore_logger_test_exe = executable(
'MMCoreLoggerTest',
sources: 'Logger-Tests.cpp',
include_directories: mmcore_include_dir,
link_with: mmcore_lib,
dependencies: [
mmdevice_dep,
gtest_dep,
],
cpp_args: [
'-D_CRT_SECURE_NO_WARNINGS', # TODO Eliminate the need
],
)

test('MMCore Logger test', mmcore_logger_test_exe)

mmcore_loggingsplitentryintolines_test_exe = executable(
'MMCoreLoggingSplitEntryIntoLinesTest',
sources: 'LoggingSplitEntryIntoLines-Tests.cpp',
include_directories: mmcore_include_dir,
link_with: mmcore_lib,
dependencies: [
mmdevice_dep,
gtest_dep,
],
cpp_args: [
'-D_CRT_SECURE_NO_WARNINGS', # TODO Eliminate the need
],
)

test(
'MMCore LoggingSplitEntryIntoLines test',
mmcore_loggingsplitentryintolines_test_exe
)
60 changes: 60 additions & 0 deletions MMDevice/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This Meson script is experimental and potentially incomplete. It is not part
# of the supported build system for Micro-Manager or mmCoreAndDevices.

project(
'MMDevice',
'cpp',
meson_version: '>=1.1.0', # May relax
default_options: [
'cpp_std=c++14',
'warning_level=3',
],
)

# We intentionally do NOT define NOMINMAX on Windows. MMDevice should compile
# correctly with or without Windows.h's min()/max() macros.

mmdevice_sources = files(
'Debayer.cpp',
'DeviceUtils.cpp',
'ImgBuffer.cpp',
'MMDevice.cpp',
'ModuleInterface.cpp',
'Property.cpp',
)

mmdevice_include_dir = include_directories('.')

mmdevice_public_headers = files(
'Debayer.h',
'DeviceBase.h',
'DeviceThreads.h',
'DeviceUtils.h',
'ImageMetadata.h',
'ImgBuffer.h',
'MMDevice.h',
'MMDeviceConstants.h',
'ModuleInterface.h',
'Property.h',
)
# TODO Support installing public headers

mmdevice_lib = static_library(
'MMDevice',
sources: mmdevice_sources,
include_directories: mmdevice_include_dir,
cpp_args: [
'-DMODULE_EXPORTS',
'-D_CRT_SECURE_NO_WARNINGS', # TODO Eliminate the need
],
# 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.
)

subdir('unittest')

mmdevice = declare_dependency(
include_directories: mmdevice_include_dir,
link_with: mmdevice_lib,
)
10 changes: 10 additions & 0 deletions MMDevice/subprojects/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/packagecache/

# Subprojects installed by meson wrap
/*-*/

# Ignore *.wrap by default (may be auto-installed transitive dependencies)
/*.wrap

# Do not ignore wraps we provide
!/gtest.wrap
16 changes: 16 additions & 0 deletions MMDevice/subprojects/gtest.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[wrap-file]
directory = googletest-1.14.0
source_url = https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz
source_filename = gtest-1.14.0.tar.gz
source_hash = 8ad598c73ad796e0d8280b082cebd82a630d73e73cd3c70057938a6501bba5d7
patch_filename = gtest_1.14.0-1_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/gtest_1.14.0-1/get_patch
patch_hash = 2e693c7d3f9370a7aa6dac802bada0874d3198ad4cfdf75647b818f691182b50
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/gtest_1.14.0-1/gtest-1.14.0.tar.gz
wrapdb_version = 1.14.0-1

[provide]
gtest = gtest_dep
gtest_main = gtest_main_dep
gmock = gmock_dep
gmock_main = gmock_main_dep
32 changes: 32 additions & 0 deletions MMDevice/unittest/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This Meson script is experimental and potentially incomplete. It is not part
# of the supported build system for Micro-Manager or mmCoreAndDevices.

gtest_proj = subproject('gtest')
gtest_dep = gtest_proj.get_variable('gtest_dep')

# TODO: Use a single executable for all tests -- but that requires modifying
# the sources (to remove main()), so needs to wait until we remove these tests
# from the Automake build.

mmdevice_floatpropertytruncation_test_exe = executable(
'MMDeviceFloatPropertyTruncationTest',
sources: 'FloatPropertyTruncation-Tests.cpp',
include_directories: mmdevice_include_dir,
link_with: mmdevice_lib,
dependencies: gtest_dep,
)

test(
'MMDevice FloatPropertyTruncation test',
mmdevice_floatpropertytruncation_test_exe,
)

mmdevice_mmtime_test_exe = executable(
'MMDeviceMMTimeTest',
sources: 'MMTime-Tests.cpp',
include_directories: mmdevice_include_dir,
link_with: mmdevice_lib,
dependencies: gtest_dep,
)

test('MMDevice MMTime test', mmdevice_mmtime_test_exe)

0 comments on commit 8c02aaa

Please sign in to comment.