Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
89 changes: 9 additions & 80 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,80 +1,21 @@
cmake_minimum_required(VERSION 3.23)

project(ScopeWriter VERSION 0.1.0 LANGUAGES C CXX)
project(ScopeWriter VERSION 0.2.0 LANGUAGES C CXX)

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

option(SCOPEWRITER_BUILD_TESTS "Build ScopeWriter tests" ${PROJECT_IS_TOP_LEVEL})

set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(_scopewriter_third_party_dir "${CMAKE_CURRENT_SOURCE_DIR}/third_party")

set(ZLIB_BUILD_EXAMPLES OFF)
set(SKIP_INSTALL_ALL ON)
add_subdirectory(
"${_scopewriter_third_party_dir}/zlib"
"${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib"
EXCLUDE_FROM_ALL
)
unset(SKIP_INSTALL_ALL)
# A parent project may already provide ZLIB::ZLIB (e.g. via a static Qt build).
if (NOT TARGET ZLIB::ZLIB)
add_library(ZLIB::ZLIB ALIAS zlibstatic)
endif ()

set(CRC32C_BUILD_TESTS OFF)
set(CRC32C_BUILD_BENCHMARKS OFF)
set(CRC32C_USE_GLOG OFF)
set(CRC32C_INSTALL OFF)
add_subdirectory(
"${_scopewriter_third_party_dir}/crc32c"
"${CMAKE_CURRENT_BINARY_DIR}/third_party/crc32c"
EXCLUDE_FROM_ALL
)
add_library(Crc32c::crc32c ALIAS crc32c)

set(ZSTD_BUILD_PROGRAMS OFF)
set(ZSTD_BUILD_SHARED OFF)
set(ZSTD_BUILD_STATIC ON)
set(ZSTD_BUILD_TESTS OFF)
set(ZSTD_BUILD_CONTRIB OFF)
set(ZSTD_LEGACY_SUPPORT OFF)
set(ZSTD_MULTITHREAD_SUPPORT OFF)
add_subdirectory(
"${_scopewriter_third_party_dir}/zstd/build/cmake"
"${CMAKE_CURRENT_BINARY_DIR}/third_party/zstd"
EXCLUDE_FROM_ALL
)

set(tiff-static ON)
set(tiff-tools OFF)
set(tiff-tests OFF)
set(tiff-contrib OFF)
set(tiff-docs OFF)
set(tiff-install OFF)
set(tiff-cxx OFF)
set(zlib ON)
set(libdeflate OFF)
set(jpeg OFF)
set(old-jpeg OFF)
set(jpeg12 OFF)
set(jbig OFF)
set(lerc OFF)
set(lzma OFF)
set(zstd OFF)
set(webp OFF)
add_subdirectory(
"${_scopewriter_third_party_dir}/libtiff"
"${CMAKE_CURRENT_BINARY_DIR}/third_party/libtiff"
EXCLUDE_FROM_ALL
)

find_package(ZLIB REQUIRED)
find_package(zstd CONFIG REQUIRED)
find_package(TIFF REQUIRED)
find_package(Crc32c CONFIG REQUIRED)
find_package(Threads REQUIRED)
set(_scopewriter_zarr_libraries
Crc32c::crc32c
libzstd_static
zstd::libzstd
Threads::Threads
)

Expand Down Expand Up @@ -108,15 +49,15 @@ set_target_properties(ScopeWriter PROPERTIES
)

target_compile_features(ScopeWriter PUBLIC cxx_std_20)
target_compile_definitions(ScopeWriter PRIVATE SCOPEWRITER_EXPORTS)
target_compile_definitions(ScopeWriter PRIVATE SCOPEWRITER_EXPORTS SCOPEWRITER_VERSION_STRING="${PROJECT_VERSION}")

target_include_directories(ScopeWriter
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_link_libraries(ScopeWriter PRIVATE TIFF::tiff ZLIB::ZLIB)
target_link_libraries(ScopeWriter PRIVATE TIFF::TIFF ZLIB::ZLIB)
target_link_libraries(ScopeWriter PRIVATE ${_scopewriter_zarr_libraries})

if (MSVC)
Expand All @@ -136,7 +77,7 @@ if (SCOPEWRITER_BUILD_TESTS)
target_compile_features(ScopeWriterTests PRIVATE cxx_std_20)
target_link_libraries(ScopeWriterTests PRIVATE
ScopeWriter
TIFF::tiff
TIFF::TIFF
${_scopewriter_zarr_libraries}
)
add_test(NAME ScopeWriterTests COMMAND ScopeWriterTests)
Expand Down Expand Up @@ -164,18 +105,6 @@ install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(FILES README.md LICENSE THIRD_PARTY_NOTICES.md
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/ScopeWriter"
)
install(FILES third_party/libtiff/LICENSE.md
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/ScopeWriter/licenses/libtiff"
)
install(FILES third_party/zlib/LICENSE
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/ScopeWriter/licenses/zlib"
)
install(FILES third_party/zstd/LICENSE
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/ScopeWriter/licenses/zstd"
)
install(FILES third_party/crc32c/LICENSE
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/ScopeWriter/licenses/crc32c"
)
install(EXPORT ScopeWriterTargets
FILE ScopeWriterTargets.cmake
NAMESPACE ScopeWriter::
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ zero `significantBits` uses the pixel type width.

## Build

Requires CMake 3.23 or newer and a C++20 compiler. Dependencies are bundled.
Requires CMake 3.23 or newer and a C++20 compiler. libtiff, zlib, Zstandard, and CRC32C are declared in `vcpkg.json` and installed by vcpkg when the vcpkg toolchain is used.

```powershell
cmake -S . -B build
cmake -S . -B build "-DCMAKE_TOOLCHAIN_FILE=$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
cmake --build build --config Release
ctest --test-dir build -C Release --output-on-failure
cmake --install build --config Release --prefix install
```

## Use

From source:
From source (the parent project must provide the same dependencies, for example by listing them in its own `vcpkg.json`):

```cmake
add_subdirectory(ScopeWriter)
Expand Down
7 changes: 3 additions & 4 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Third-party notices

ScopeWriter links libtiff, zlib, Zstandard, and CRC32C, which are provided by
vcpkg (see `vcpkg.json`) under their own licenses.

ScopeWriter includes the following third-party code under its original terms:

| Component | License file |
| --- | --- |
| libtiff | `third_party/libtiff/LICENSE.md` |
| zlib | `third_party/zlib/LICENSE` |
| Zstandard | `third_party/zstd/LICENSE` |
| CRC32C | `third_party/crc32c/LICENSE` |
| acquire-zarr | Full text below |

Parts of `src/zarr` and `src/ZarrWriter.cpp` are derived from acquire-zarr and
Expand Down
1 change: 1 addition & 0 deletions include/scopewriter/ScopeWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace scopewriter
"pixel_format,pixel_format_id,payload_bytes,source_roi_x,source_roi_y,"
"source_roi_width,source_roi_height";

SCOPEWRITER_API std::string version();
SCOPEWRITER_API std::string libTiffVersion();
SCOPEWRITER_API std::string zlibVersion();

Expand Down
5 changes: 5 additions & 0 deletions src/ScopeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
namespace scopewriter
{
// Return the bundled libtiff version
std::string version()
{
return SCOPEWRITER_VERSION_STRING;
}

std::string libTiffVersion()
{
std::string version = TIFFGetVersion();
Expand Down
6 changes: 6 additions & 0 deletions tests/consumer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ add_test(NAME ScopeWriterInstalledConsumer
COMMAND ScopeWriterConsumer
"${CMAKE_CURRENT_BINARY_DIR}/consumer.ome.tiff"
)
if (WIN32)
# Dependency DLLs are installed next to ScopeWriter.dll
set_tests_properties(ScopeWriterInstalledConsumer PROPERTIES
ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:ScopeWriter::ScopeWriter>"
)
endif ()
3 changes: 0 additions & 3 deletions third_party/crc32c/.clang-format

This file was deleted.

8 changes: 0 additions & 8 deletions third_party/crc32c/.clang_complete

This file was deleted.

102 changes: 0 additions & 102 deletions third_party/crc32c/.github/workflows/build.yml

This file was deleted.

9 changes: 0 additions & 9 deletions third_party/crc32c/.gitignore

This file was deleted.

9 changes: 0 additions & 9 deletions third_party/crc32c/.gitmodules

This file was deleted.

Loading
Loading