diff --git a/CMakeLists.txt b/CMakeLists.txt index ad70e1817b..638cc06fed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/cmake/DetectOptions.cmake b/cmake/DetectOptions.cmake index 99d2d45cb1..5b71c1565b 100644 --- a/cmake/DetectOptions.cmake +++ b/cmake/DetectOptions.cmake @@ -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_$,shared,static>) + endif() + + add_library(adios2_blosc2 INTERFACE) + target_link_libraries(adios2_blosc2 INTERFACE ${adios2_blosc2_tgt}) endif() # BZip2 diff --git a/source/adios2/CMakeLists.txt b/source/adios2/CMakeLists.txt index 659ca94e70..8ce49a6904 100644 --- a/source/adios2/CMakeLists.txt +++ b/source/adios2/CMakeLists.txt @@ -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) @@ -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