Skip to content

Commit

Permalink
Standalone 1/N: Move driver source and test files to separate directo…
Browse files Browse the repository at this point in the history
…ries (#293)

Splitting up #291. Moves files and updates CMakeLists.txt files
accordingly.
  • Loading branch information
aliddell authored Sep 18, 2024
1 parent e5a27d1 commit 8084499
Show file tree
Hide file tree
Showing 67 changed files with 150 additions and 142 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

option(NOTEST "Disable all tests" OFF)
option(BUILD_ACQUIRE_DRIVER_ZARR "Build the Acquire Zarr driver" ON)

add_subdirectory(src)
add_subdirectory(tests)
add_subdirectory(examples)
Expand Down
58 changes: 2 additions & 56 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,57 +1,3 @@
if (NOT TARGET acquire-core-logger)
add_subdirectory(../acquire-common/acquire-core-libs ${CMAKE_CURRENT_BINARY_DIR}/acquire-core-libs)
if (BUILD_ACQUIRE_DRIVER_ZARR)
add_subdirectory(driver)
endif ()

set(tgt acquire-driver-zarr)
add_library(${tgt} MODULE
common/dimension.hh
common/dimension.cpp
common/thread.pool.hh
common/thread.pool.cpp
common/s3.connection.hh
common/s3.connection.cpp
common/utilities.hh
common/utilities.cpp
writers/sink.hh
writers/sink.creator.hh
writers/sink.creator.cpp
writers/file.sink.hh
writers/file.sink.cpp
writers/s3.sink.hh
writers/s3.sink.cpp
writers/array.writer.hh
writers/array.writer.cpp
writers/zarrv2.array.writer.hh
writers/zarrv2.array.writer.cpp
writers/zarrv3.array.writer.hh
writers/zarrv3.array.writer.cpp
writers/blosc.compressor.hh
writers/blosc.compressor.cpp
zarr.hh
zarr.cpp
zarr.v2.hh
zarr.v2.cpp
zarr.v3.hh
zarr.v3.cpp
zarr.driver.c
)

target_include_directories(${tgt} PRIVATE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src>
)

target_enable_simd(${tgt})
target_link_libraries(${tgt} PRIVATE
acquire-core-logger
acquire-core-platform
acquire-device-kit
acquire-device-properties
blosc_static
nlohmann_json::nlohmann_json
miniocpp::miniocpp
)
set_target_properties(${tgt} PROPERTIES
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
)

install(TARGETS ${tgt} LIBRARY DESTINATION lib)
57 changes: 57 additions & 0 deletions src/driver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
if (NOT TARGET acquire-core-logger)
add_subdirectory(${CMAKE_SOURCE_DIR}/acquire-common/acquire-core-libs ${CMAKE_CURRENT_BINARY_DIR}/acquire-core-libs)
endif ()

set(tgt acquire-driver-zarr)
add_library(${tgt} MODULE
common/dimension.hh
common/dimension.cpp
common/thread.pool.hh
common/thread.pool.cpp
common/s3.connection.hh
common/s3.connection.cpp
common/utilities.hh
common/utilities.cpp
writers/sink.hh
writers/sink.creator.hh
writers/sink.creator.cpp
writers/file.sink.hh
writers/file.sink.cpp
writers/s3.sink.hh
writers/s3.sink.cpp
writers/array.writer.hh
writers/array.writer.cpp
writers/zarrv2.array.writer.hh
writers/zarrv2.array.writer.cpp
writers/zarrv3.array.writer.hh
writers/zarrv3.array.writer.cpp
writers/blosc.compressor.hh
writers/blosc.compressor.cpp
zarr.hh
zarr.cpp
zarr.v2.hh
zarr.v2.cpp
zarr.v3.hh
zarr.v3.cpp
zarr.driver.c
)

target_include_directories(${tgt} PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)

target_enable_simd(${tgt})
target_link_libraries(${tgt} PRIVATE
acquire-core-logger
acquire-core-platform
acquire-device-kit
acquire-device-properties
blosc_static
nlohmann_json::nlohmann_json
miniocpp::miniocpp
)
set_target_properties(${tgt} PROPERTIES
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
)

install(TARGETS ${tgt} LIBRARY DESTINATION lib)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
89 changes: 3 additions & 86 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,90 +1,7 @@
if (${NOTEST})
message(STATUS "Skipping test targets")
else ()
set(NOTEST "TRUE")
add_subdirectory(../acquire-common/acquire-driver-common ${CMAKE_CURRENT_BINARY_DIR}/acquire-driver-common)
add_subdirectory(../acquire-common/acquire-video-runtime ${CMAKE_CURRENT_BINARY_DIR}/acquire-video-runtime)
set(NOTEST "FALSE")

#
# PARAMETERS
#
set(project acquire-driver-zarr) # CMAKE_PROJECT_NAME gets overridden if this is a subtree of another project

#
# Tests
#
set(tests
list-devices
unit-tests
get
get-meta
get-set-get
external-metadata-with-whitespace-ok
restart-stopped-zarr-resets-threadpool
repeat-start
metadata-dimension-sizes
write-zarr-v2-raw
write-zarr-v2-raw-chunk-size-larger-than-frame-size
write-zarr-v2-raw-with-even-chunking
write-zarr-v2-raw-with-even-chunking-and-rollover
write-zarr-v2-raw-with-ragged-chunking
write-zarr-v2-with-lz4-compression
write-zarr-v2-with-zstd-compression
write-zarr-v2-compressed-with-chunking
write-zarr-v2-compressed-with-chunking-and-rollover
write-zarr-v2-raw-multiscale
write-zarr-v2-raw-multiscale-with-trivial-tile-size
write-zarr-v2-compressed-multiscale
write-zarr-v2-to-s3
multiscales-metadata
write-zarr-v3-raw
write-zarr-v3-raw-with-ragged-sharding
write-zarr-v3-raw-chunk-exceeds-array
write-zarr-v3-compressed
write-zarr-v3-raw-multiscale
write-zarr-v3-to-s3
)

foreach (name ${tests})
set(tgt "${project}-${name}")
add_executable(${tgt} ${name}.cpp)
target_compile_definitions(${tgt} PUBLIC "TEST=\"${tgt}\"")
set_target_properties(${tgt} PROPERTIES
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
)
target_include_directories(${tgt} PRIVATE "${CMAKE_CURRENT_LIST_DIR}/../")
target_link_libraries(${tgt}
acquire-core-logger
acquire-core-platform
acquire-video-runtime
nlohmann_json::nlohmann_json
miniocpp::miniocpp
)

add_test(NAME test-${tgt} COMMAND ${tgt})
set_tests_properties(test-${tgt} PROPERTIES LABELS "anyplatform;acquire-driver-zarr")
endforeach ()

#
# Copy driver to tests
#
list(POP_FRONT tests onename)

foreach (driver
acquire-driver-common
acquire-driver-zarr
)
add_custom_target(${project}-copy-${driver}-for-tests
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:${driver}>
$<TARGET_FILE_DIR:${project}-${onename}>
DEPENDS ${driver}
COMMENT "Copying ${driver} to $<TARGET_FILE_DIR:${project}-${onename}>"
)

foreach (name ${tests})
add_dependencies(${tgt} ${project}-copy-${driver}-for-tests)
endforeach ()
endforeach ()
if (BUILD_ACQUIRE_DRIVER_ZARR)
add_subdirectory(driver)
endif ()
endif ()
85 changes: 85 additions & 0 deletions tests/driver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
set(NOTEST "TRUE")
add_subdirectory(${CMAKE_SOURCE_DIR}/acquire-common ${CMAKE_CURRENT_BINARY_DIR}/acquire-common)
set(NOTEST "FALSE")

#
# PARAMETERS
#
set(project acquire-driver-zarr) # CMAKE_PROJECT_NAME gets overridden if this is a subtree of another project

#
# Tests
#
set(tests
list-devices
unit-tests
get
get-meta
get-set-get
external-metadata-with-whitespace-ok
restart-stopped-zarr-resets-threadpool
repeat-start
metadata-dimension-sizes
write-zarr-v2-raw
write-zarr-v2-raw-chunk-size-larger-than-frame-size
write-zarr-v2-raw-with-even-chunking
write-zarr-v2-raw-with-even-chunking-and-rollover
write-zarr-v2-raw-with-ragged-chunking
write-zarr-v2-with-lz4-compression
write-zarr-v2-with-zstd-compression
write-zarr-v2-compressed-with-chunking
write-zarr-v2-compressed-with-chunking-and-rollover
write-zarr-v2-raw-multiscale
write-zarr-v2-raw-multiscale-with-trivial-tile-size
write-zarr-v2-compressed-multiscale
write-zarr-v2-to-s3
multiscales-metadata
write-zarr-v3-raw
write-zarr-v3-raw-with-ragged-sharding
write-zarr-v3-raw-chunk-exceeds-array
write-zarr-v3-compressed
write-zarr-v3-raw-multiscale
write-zarr-v3-to-s3
)

foreach (name ${tests})
set(tgt "${project}-${name}")
add_executable(${tgt} ${name}.cpp)
target_compile_definitions(${tgt} PUBLIC "TEST=\"${tgt}\"")
set_target_properties(${tgt} PROPERTIES
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
)
target_include_directories(${tgt} PRIVATE "${CMAKE_CURRENT_LIST_DIR}/../")
target_link_libraries(${tgt}
acquire-core-logger
acquire-core-platform
acquire-video-runtime
nlohmann_json::nlohmann_json
miniocpp::miniocpp
)

add_test(NAME test-${tgt} COMMAND ${tgt})
set_tests_properties(test-${tgt} PROPERTIES LABELS "anyplatform;acquire-driver-zarr")
endforeach ()

#
# Copy driver to tests
#
list(POP_FRONT tests onename)

foreach (driver
acquire-driver-common
acquire-driver-zarr
)
add_custom_target(${project}-copy-${driver}-for-tests
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:${driver}>
$<TARGET_FILE_DIR:${project}-${onename}>
DEPENDS ${driver}
COMMENT "Copying ${driver} to $<TARGET_FILE_DIR:${project}-${onename}>"
)

foreach (name ${tests})
add_dependencies(${tgt} ${project}-copy-${driver}-for-tests)
endforeach ()
endforeach ()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 8084499

Please sign in to comment.