Skip to content

Commit

Permalink
cmake: Add Blosc2 2.10.1 compatibility.
Browse files Browse the repository at this point in the history
- Give priority to Blosc2Config.cmake file rather than FindBlosc2.cmake.
- Prefer shared Blosc2 library.

Co-Authored-By: Axel Huebl <axel.huebl@plasma.ninja>
  • Loading branch information
vicentebolea and ax3l committed Aug 10, 2023
1 parent afbe6d6 commit 8333d5e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ if(ADIOS2_HAVE_MPI)
add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
endif()

cmake_dependent_option(ADIOS2_Blosc2_PREFER_SHARED "Prefer shared Blosc2 libraries"
ON "Blosc2_shlib_available" OFF)

#------------------------------------------------------------------------------#
# POSIX O_DIRECT is only working for Unix in adios for now
Expand Down
25 changes: 22 additions & 3 deletions cmake/DetectOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,31 @@ endfunction()

# Blosc2
if(ADIOS2_USE_Blosc2 STREQUAL AUTO)
find_package(Blosc2 2.4)
# Prefect CONFIG mode
find_package(Blosc2 2.4 CONFIG QUIET)
if(NOT Blosc2_FOUND)
find_package(Blosc2 2.4 MODULE QUIET)
endif()
elseif(ADIOS2_USE_Blosc2)
find_package(Blosc2 2.4 REQUIRED)
# Prefect CONFIG mode
find_package(Blosc2 2.4 CONFIG REQUIRED)
if(NOT Blosc2_FOUND)
find_package(Blosc2 2.4 MODULE REQUIRED)
endif()
endif()
if(BLOSC2_FOUND)
if(Blosc2_FOUND)
set(ADIOS2_HAVE_Blosc2 TRUE)
if(TARGET Blosc2::blosc2_shared)
set(Blosc2_shlib_available ON)
endif()

set(adios2_blosc2_tgt Blosc2::Blosc2)
if (Blosc2_VERSION VERSION_GREATER_EQUAL 2.10.1)
set(adios2_blosc2_tgt Blosc2::blosc2_$<IF:$<BOOL:${ADIOS2_Blosc2_PREFER_SHARED}>,shared,static>)
endif()

add_library(adios2_blosc2 INTERFACE)
target_link_libraries(adios2_blosc2 INTERFACE ${adios2_blosc2_tgt})
endif()

# BZip2
Expand Down
6 changes: 4 additions & 2 deletions source/adios2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,11 @@ if(ADIOS2_HAVE_DataSpaces)
target_link_libraries(adios2_core_mpi PRIVATE DataSpaces::DataSpaces)
endif()

set(maybe_adios2_blosc2)
if(ADIOS2_HAVE_Blosc2)
target_sources(adios2_core PRIVATE operator/compress/CompressBlosc.cpp)
target_link_libraries(adios2_core PRIVATE Blosc2::Blosc2)
target_link_libraries(adios2_core PRIVATE adios2_blosc2)
set(maybe_adios2_blosc2 adios2_blosc2)
endif()

if(ADIOS2_HAVE_BZip2)
Expand Down Expand Up @@ -448,7 +450,7 @@ install(DIRECTORY toolkit/
)

# Library installation
install(TARGETS adios2_core ${maybe_adios2_core_mpi} ${maybe_adios2_core_cuda} ${maybe_adios2_core_kokkos} EXPORT adios2Exports
install(TARGETS adios2_core ${maybe_adios2_core_mpi} ${maybe_adios2_core_cuda} ${maybe_adios2_core_kokkos} ${maybe_adios2_blosc2} EXPORT adios2Exports
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT adios2_core-runtime
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT adios2_core-libraries NAMELINK_COMPONENT adios2_core-development
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT adios2_core-development
Expand Down

0 comments on commit 8333d5e

Please sign in to comment.