Skip to content

Commit

Permalink
cmake: keep compatibility with blosc2 < 2.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
vicentebolea committed Aug 10, 2023
1 parent 9273f1d commit 4481696
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,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
22 changes: 19 additions & 3 deletions cmake/DetectOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,30 @@ function(lists_get_prefix listVars outVar)
endfunction()

# Blosc2
option(ADIOS2_PREFER_SHARED_Blosc2 "prefer sharred Blosc2 libraries" ON)
if(ADIOS2_USE_Blosc2 STREQUAL AUTO)
find_package(Blosc2 2.10.1 CONFIG)
# 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.10.1 CONFIG 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)
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:${ADIO2_Blosc2_PREFER_SHARED}>,shared,static>)
endif()
add_library(adios2_blosc2 ALIAS ${adios2_blosc2_tgt})
endif()

# BZip2
Expand Down
6 changes: 1 addition & 5 deletions source/adios2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,7 @@ endif()

if(ADIOS2_HAVE_Blosc2)
target_sources(adios2_core PRIVATE operator/compress/CompressBlosc.cpp)
if(ADIOS2_PREFER_SHARED_Blosc2 AND TARGET Blosc2::blosc2_shared)
target_link_libraries(adios2_core PRIVATE Blosc2::blosc2_shared)
else()
target_link_libraries(adios2_core PRIVATE Blosc2::blosc2_static)
endif()
target_link_libraries(adios2_core PRIVATE adios2_blosc2)
endif()

if(ADIOS2_HAVE_BZip2)
Expand Down

0 comments on commit 4481696

Please sign in to comment.