Skip to content
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
Language: Cpp
BasedOnStyle: Microsoft
Standard: Latest

IndentWidth: 4
TabWidth: 4
UseTab: Never
ColumnLimit: 120

BreakBeforeBraces: Allman
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: MultiLine
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: true
BeforeWhile: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true

NamespaceIndentation: All
FixNamespaceComments: true
CompactNamespaces: false

AccessModifierOffset: -4
IndentAccessModifiers: false

PointerAlignment: Left
ReferenceAlignment: Left
DerivePointerAlignment: false

AlignAfterOpenBracket: AlwaysBreak
BinPackArguments: false
BinPackParameters: false
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
PenaltyBreakBeforeFirstCallParameter: 0

ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
IndentWrappedFunctionNames: false

AllowShortFunctionsOnASingleLine: Empty
AllowShortBlocksOnASingleLine: Never
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false

AlwaysBreakTemplateDeclarations: Yes
BreakConstructorInitializers: BeforeComma
PackConstructorInitializers: Never

Cpp11BracedListStyle: true
SpaceBeforeCpp11BracedList: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceInEmptyParentheses: false
SpaceBeforeParens: ControlStatements
SpaceAfterTemplateKeyword: false

SortIncludes: CaseSensitive
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<.*>$'
Priority: 1
- Regex: '^"(blosc2|nlohmann|nvcomp|cuda|cuda_runtime).*'
Priority: 2
- Regex: '^".*"$'
Priority: 3

ReflowComments: true
AlignTrailingComments: true
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 2

DeriveLineEnding: true
InsertNewlineAtEOF: true
...
1 change: 1 addition & 0 deletions .clang-format-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
thirdparty/**
42 changes: 42 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Checks: >
-*,
readability-identifier-naming

CheckOptions:
- key: readability-identifier-naming.FunctionCase
value: lower_case
- key: readability-identifier-naming.MethodCase
value: lower_case
- key: readability-identifier-naming.VariableCase
value: lower_case

# Allow local temporaries like _compressor
- key: readability-identifier-naming.LocalVariableCase
value: lower_case
- key: readability-identifier-naming.LocalVariableIgnoredRegexp
value: '^_[a-z0-9_]+$'

# Public members: no prefix
- key: readability-identifier-naming.PublicMemberCase
value: lower_case

# Protected members: m_ prefix
- key: readability-identifier-naming.ProtectedMemberCase
value: lower_case
- key: readability-identifier-naming.ProtectedMemberPrefix
value: m_

# Private members: m_ prefix
- key: readability-identifier-naming.PrivateMemberCase
value: lower_case
- key: readability-identifier-naming.PrivateMemberPrefix
value: m_

- key: readability-identifier-naming.ClassCase
value: lower_case
- key: readability-identifier-naming.StructCase
value: lower_case
- key: readability-identifier-naming.EnumCase
value: lower_case
- key: readability-identifier-naming.EnumConstantCase
value: lower_case
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ benchmark/images/*.tga
# Release artifacts
release/

.idea/

# Wheel Artifacts
wheels/
wheelhouse/
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@
[submodule "thirdparty/pybind11_json"]
path = thirdparty/pybind11_json
url = https://github.com/pybind/pybind11_json
[submodule "thirdparty/spdlog"]
path = thirdparty/spdlog
url = https://github.com/gabime/spdlog
124 changes: 71 additions & 53 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,37 +1,42 @@
cmake_minimum_required (VERSION 3.19)
cmake_minimum_required(VERSION 3.19)
set(VCPKG_LIBRARY_LINKAGE static)

if (POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif ()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set (CMAKE_CXX_STANDARD 20)
project (CompressedImageBuild)
set(CMAKE_CXX_STANDARD 20)
project(CompressedImageBuild)

# If we are compiling as the main project we automatically turn on all the build options.
# This can be circumvented by passing "-DCOMPRESSED_DETERMINE_MAIN_PROJECT=OFF"
set(MAIN_PROJECT OFF)
option (
COMPRESSED_DETERMINE_MAIN_PROJECT
"Whether to automatically determine if we are building this module as main project"
ON
option(
COMPRESSED_DETERMINE_MAIN_PROJECT
"Whether to automatically determine if we are building this module as main project"
ON
)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR AND COMPRESSED_DETERMINE_MAIN_PROJECT)
message("Compiling compressed-image as main project")
set(MAIN_PROJECT ON)
else()
set(MAIN_PROJECT OFF)
endif()
message("Compiling compressed-image as main project")
set(MAIN_PROJECT ON)
else ()
set(MAIN_PROJECT OFF)
endif ()

if (MAIN_PROJECT)
set(COMPRESSED_IMAGE_USE_VCPKG ON)
set(COMPRESSED_IMAGE_BUILD_TESTS ON)
set(COMPRESSED_IMAGE_BUILD_EXAMPLES ON)
set(COMPRESSED_IMAGE_BUILD_PYTHON ON)
set(COMPRESSED_IMAGE_BUILD_DOCS ON)
set(COMPRESSED_IMAGE_BUILD_BENCHMARKS ON)
set(COMPRESSED_IMAGE_EXTENDED_WARNINGS ON)
endif()
set(COMPRESSED_IMAGE_USE_VCPKG ON)
set(COMPRESSED_IMAGE_BUILD_TESTS ON)
set(COMPRESSED_IMAGE_BUILD_EXAMPLES ON)
set(COMPRESSED_IMAGE_BUILD_PYTHON ON)
set(COMPRESSED_IMAGE_BUILD_DOCS ON)
set(COMPRESSED_IMAGE_BUILD_BENCHMARKS ON)
set(COMPRESSED_IMAGE_EXTENDED_WARNINGS ON)
endif ()

option(COMPRESSED_IMAGE_USE_VCPKG "Whether to use the submodule version of vcpkg to resolve the dependencies instead of system libraries." OFF)
option(COMPRESSED_IMAGE_EXTENDED_WARNINGS "Whether to compile with extended warnings (-Wextra, -Werror etc.)" OFF)
option(COMPRESSED_IMAGE_CUDA_VERSION "CUDA Runtime/Toolkit version" 12)
option(COMPRESSED_IMAGE_BUILD_TESTS OFF)
option(COMPRESSED_IMAGE_BUILD_EXAMPLES OFF)
option(COMPRESSED_IMAGE_BUILD_DOCS OFF)
Expand All @@ -44,70 +49,83 @@ option(_COMPRESSED_IMAGE_SANITIZE_FLAGS "Internal CI flag for enabling sanitizer
# Add thirdparty libraries
# --------------------------------------------------------------------------

find_package(CUDAToolkit REQUIRED COMPRESSED_IMAGE_CUDA_VERSION)

# Add c-blosc2
set(DEACTIVATE_ZLIB ON)
set(BUILD_TESTS OFF)
set(BUILD_FUZZERS OFF)
set(BUILD_BENCHMARKS OFF)
set(BUILD_EXAMPLES OFF)
add_subdirectory (thirdparty/c-blosc2)
add_subdirectory(thirdparty/c-blosc2)

# Add target for blosc2 headers
add_library(blosc2_include INTERFACE)
target_include_directories(blosc2_include SYSTEM INTERFACE thirdparty/c-blosc2/include)
target_include_directories(blosc2_include SYSTEM INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/c-blosc2/include>
$<INSTALL_INTERFACE:include>
)


# JSON module for parsing/storing metadata
add_subdirectory(thirdparty/json)

# spdlog for logging
set(SPDLOG_USE_STD_FORMAT ON)
add_subdirectory(thirdparty/spdlog)

# Pull nvcomp (headers + dll/so target)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/FetchNvcomp.cmake)

# Include the local vcpkg toolchain, if requested, otherwise it is up to the user
# to provide a valid OpenImageIO library (that can be found via find_package)
if (COMPRESSED_IMAGE_USE_VCPKG)
include("${PROJECT_SOURCE_DIR}/thirdparty/vcpkg/scripts/buildsystems/vcpkg.cmake")
endif()
include("${CMAKE_CURRENT_LIST_DIR}/thirdparty/vcpkg/scripts/buildsystems/vcpkg.cmake")
endif ()

find_package(OpenImageIO CONFIG QUIET)
if (OpenImageIO_FOUND)
message(STATUS "Found OpenImageIO")
set(COMPRESSED_IMAGE_HAVE_OIIO TRUE)
else()
message(WARNING "OpenImageIO not found, some features will not be available")
set(COMPRESSED_IMAGE_HAVE_OIIO TRUE)
endif()
message(STATUS "Found OpenImageIO")
set(COMPRESSED_IMAGE_HAVE_OIIO TRUE)
else ()
message(WARNING "OpenImageIO not found, some features will not be available")
set(COMPRESSED_IMAGE_HAVE_OIIO FALSE)
endif ()

# Projects
# --------------------------------------------------------------------------
add_subdirectory(compressed_image)

if (COMPRESSED_IMAGE_BUILD_TESTS)
add_library(doctest INTERFACE)
target_include_directories(doctest SYSTEM INTERFACE thirdparty/doctest/doctest)
add_library(doctest INTERFACE)
target_include_directories(doctest SYSTEM INTERFACE thirdparty/doctest/doctest)

add_subdirectory(test)
endif()
add_subdirectory(test)
endif ()

if (COMPRESSED_IMAGE_BUILD_EXAMPLES)
add_subdirectory(examples/read_from_file)
add_subdirectory(examples/read_with_postprocess)
add_subdirectory(examples/lazy_channels)
add_subdirectory(examples/modifying_image)
endif()
add_subdirectory(examples/read_from_file)
add_subdirectory(examples/read_with_postprocess)
add_subdirectory(examples/lazy_channels)
add_subdirectory(examples/modifying_image)
endif ()

if (COMPRESSED_IMAGE_BUILD_BENCHMARKS)
set(BENCHMARK_ENABLE_INSTALL OFF)
set(BENCHMARK_INSTALL_DOCS OFF)
set(BENCHMARK_ENABLE_TESTING OFF)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF)
add_subdirectory(thirdparty/benchmark)
add_subdirectory(benchmark)
endif()
set(BENCHMARK_ENABLE_INSTALL OFF)
set(BENCHMARK_INSTALL_DOCS OFF)
set(BENCHMARK_ENABLE_TESTING OFF)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF)
add_subdirectory(thirdparty/benchmark)
add_subdirectory(benchmark)
endif ()

if (COMPRESSED_IMAGE_BUILD_DOCS)
add_subdirectory(docs)
endif()
add_subdirectory(docs)
endif ()

if (COMPRESSED_IMAGE_BUILD_PYTHON)
add_subdirectory(thirdparty/pybind11)
add_subdirectory(thirdparty/pybind11_image_util)
add_subdirectory(thirdparty/pybind11_json)
add_subdirectory(python)
endif()
add_subdirectory(thirdparty/pybind11)
add_subdirectory(thirdparty/pybind11_image_util)
add_subdirectory(thirdparty/pybind11_json)
add_subdirectory(python)
endif ()
Loading
Loading