Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
add json.c as a dependency, find cblosc2 in the cmakelists and add a …
Browse files Browse the repository at this point in the history
…more complete cmakelists.txt
  • Loading branch information
SuperOptimizer committed Nov 11, 2024
1 parent 22c03b6 commit a3f7faf
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ example
.DS_Store
.vesuvius-cache/
*.obj

cmake-build-debug/
cmake-build-minsizerel/
cmake-build-release/
cmake-build-relwithdebinfo/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "third-party/json.h"]
path = third-party/json.h
url = https://github.com/sheredom/json.h.git
46 changes: 44 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,47 @@ cmake_minimum_required(VERSION 3.10)

project(vesuvius C)

add_executable(vesuvius_example example2.c)
add_executable(vesuvius_tests runtests.c)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

add_executable(vesuvius_example example.c)
add_executable(vesuvius_example2 example2.c)
add_executable(vesuvius_tests runtests.c)

include_directories(third-party/json.h)

find_package(Blosc2 REQUIRED)
find_package(CURL REQUIRED)

add_compile_options(-g3)
if(UNIX)
add_link_options(-rdynamic)
endif()

# For some reason, when using _just_ link_libraries, no libraries are actually linked because ???
# so just target_link_libraries for all executables
target_link_libraries(vesuvius_example PUBLIC -lm)
target_link_libraries(vesuvius_example2 PUBLIC -lm)
target_link_libraries(vesuvius_tests PUBLIC -lm)

if(Blosc2_FOUND)
message(STATUS "Found blosc2. Building with Zarr support")

target_link_libraries(vesuvius_example PUBLIC Blosc2::Blosc2)
target_link_libraries(vesuvius_example2 PUBLIC Blosc2::Blosc2)
target_link_libraries(vesuvius_tests PUBLIC Blosc2::Blosc2)
add_compile_definitions(VESUVIUS_ZARR_IMPL)
else()
message(STATUS "Blosc2 not found - building without Zarr support")
endif()

if(CURL_FOUND)
message(STATUS "Found curl. Building with Curl support")
target_link_libraries(vesuvius_example PUBLIC CURL::libcurl)
target_link_libraries(vesuvius_example2 PUBLIC CURL::libcurl)
target_link_libraries(vesuvius_tests PUBLIC CURL::libcurl)
add_compile_definitions(VESUVIUS_CURL_IMPL)
else()
message(STATUS "CURL not found - building without CURL support")
endif()


33 changes: 33 additions & 0 deletions cmake/FindBlosc2.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# FindBlosc2.cmake
# Defines:
# BLOSC2_FOUND - System has Blosc2
# BLOSC2_INCLUDE_DIRS - Blosc2 include directories
# BLOSC2_LIBRARY - Blosc2 library
# Blosc2::Blosc2 - Imported target

find_path(BLOSC2_INCLUDE_DIRS
NAMES blosc2.h
PATHS ${BLOSC2_ROOT_DIR}
PATH_SUFFIXES include
)

find_library(BLOSC2_LIBRARY
NAMES blosc2
PATHS ${BLOSC2_ROOT_DIR}
PATH_SUFFIXES lib lib64
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Blosc2
REQUIRED_VARS BLOSC2_LIBRARY BLOSC2_INCLUDE_DIRS
)

if(Blosc2_FOUND AND NOT TARGET Blosc2::Blosc2)
add_library(Blosc2::Blosc2 UNKNOWN IMPORTED)
set_target_properties(Blosc2::Blosc2 PROPERTIES
IMPORTED_LOCATION "${BLOSC2_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${BLOSC2_INCLUDE_DIRS}"
)
endif()

mark_as_advanced(BLOSC2_INCLUDE_DIRS BLOSC2_LIBRARY)

0 comments on commit a3f7faf

Please sign in to comment.