Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cmake-based libnetcdf.settings.in #2944

Merged
merged 9 commits into from
Jun 28, 2024
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ else() # No option specified
endif()

# Try to enable NCZarr zip support
option(NETCDF_ENABLE_NCZARR_ZIP "Enable NCZarr ZIP support." OFF)
option(NETCDF_ENABLE_NCZARR_ZIP "Enable NCZarr ZIP support." ${NETCDF_ENABLE_NCZARR})

include(CMakeDependentOption)

Expand Down Expand Up @@ -1730,6 +1730,8 @@ endif()
# Copy the CTest customization file into binary directory, as required.
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake")

message(STATUS "STD_FILTERS: ${STD_FILTERS}")

# Generate file from template.
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libnetcdf.settings.in"
"${CMAKE_CURRENT_BINARY_DIR}/libnetcdf.settings"
Expand Down
24 changes: 17 additions & 7 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ endif()
################################
# Zips
################################
MESSAGE(STATUS "Checking for filter libraries")
IF (NETCDF_ENABLE_FILTER_SZIP)
find_package(Szip)
elseif(NETCDF_ENABLE_NCZARR)
Expand All @@ -385,31 +386,40 @@ IF (NETCDF_ENABLE_FILTER_ZSTD)
endif()

# Accumulate standard filters
set(STD_FILTERS "deflate") # Always have deflate*/
#set(STD_FILTERS "bz2")
set(FOUND_STD_FILTERS "")
if(ENABLE_ZLIB)
set(STD_FILTERS "deflate")
endif()
set_std_filter(Szip)
set(HAVE_SZ ${Szip_FOUND})
set(USE_SZIP ${HAVE_SZ})
set_std_filter(Blosc)
if(Zstd_FOUND)
set_std_filter(Zstd)
set(HAVE_ZSTD ON)
endif()
if(Bz2_FOUND)
set_std_filter(Bz2)
else()
# The reason we use a local version is to support a more comples test case
message("libbz2 not found using built-in version")
message("libbz2 not found using built-in version")
set(HAVE_LOCAL_BZ2 ON)
set(HAVE_BZ2 ON CACHE BOOL "")
set(STD_FILTERS "${STD_FILTERS} bz2")
endif()

set(STD_FILTERS "${STD_FILTERS}${FOUND_STD_FILTERS}")
IF (NETCDF_ENABLE_NCZARR_ZIP)
find_package(Zip REQUIRED)
target_include_directories(netcdf
PRIVATE
find_package(Zip)
if(Zip_FOUND)
target_include_directories(netcdf
PRIVATE
${Zip_INCLUDE_DIRS}
)
)
else()
message(STATUS "libzip development package not found, disabling NETCDF_ENABLE_NCZARR_ZIP")
set(NETCDF_ENABLE_NCZARR_ZIP OFF CACHE BOOL "Enable NCZARR_ZIP functionality." FORCE)
endif()
endif ()

################################
Expand Down
19 changes: 9 additions & 10 deletions cmake/netcdf_functions_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,25 @@
# Macros
################################

macro(set_std_filter filter)
function(set_std_filter filter)
# Upper case the filter name
string(TOUPPER "${filter}" upfilter)
string(TOLOWER "${filter}" downfilter)
if(ENABLE_FILTER_${upfilter})
if(NETCDF_ENABLE_FILTER_${upfilter})
# Define a test flag for filter
if(${filter}_FOUND)
include_directories(${${filter}_INCLUDE_DIRS})
set(ENABLE_${upfilter} TRUE)
set(HAVE_${upfilter} ON)
set(STD_FILTERS "${STD_FILTERS} ${downfilter}")
message(">>> Standard Filter: ${downfilter}")
set(NETCDF_ENABLE_${upfilter} TRUE CACHE BOOL "Enable ${upfilter}")
set(HAVE_${upfilter} ON CACHE BOOL "Have ${upfilter}")
set(FOUND_STD_FILTERS "${FOUND_STD_FILTERS} ${downfilter}" PARENT_SCOPE)
else()
set(ENABLE_${upfilter} FALSE)
set(HAVE_${upfilter} OFF)
set(NETCDF_ENABLE_${upfilter} FALSE CACHE BOOL "Enable ${upfilter}" FORCE)
set(HAVE_${upfilter} OFF CACHE BOOL "Have ${upfilter}" FORCE)
endif()
else()
set(HAVE_${upfilter} OFF)
set(HAVE_${upfilter} OFF CACHE BOOL "Have ${upfilter}" FORCE)
endif()
endmacro(set_std_filter)
endfunction(set_std_filter)

macro(getuname name flag)
execute_process(COMMAND "${UNAME}" "${flag}" OUTPUT_VARIABLE "${name}" OUTPUT_STRIP_TRAILING_WHITESPACE)
Expand Down
1 change: 1 addition & 0 deletions libnetcdf.settings.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ S3 Support: @HAS_S3@
S3 SDK: @WHICH_S3_SDK@

NCZarr Support: @HAS_NCZARR@
NCZarr Zip Support: @HAS_NCZARR_ZIP@

Diskless Support: @HAS_DISKLESS@
MMap Support: @HAS_MMAP@
Expand Down
2 changes: 1 addition & 1 deletion nczarr_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ IF(NETCDF_ENABLE_TESTS)
if(NETCDF_ENABLE_NCZARR_ZIP)
add_sh_test(nczarr_test run_newformat)
# Test various corrupted files
ADD_SH_TEST(nczarr_test run_corrupt.sh)
ADD_SH_TEST(nczarr_test run_corrupt)
endif()

IF(FALSE) # Obsolete tests
Expand Down
8 changes: 5 additions & 3 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,18 @@ buildplugin(h5deflate "h5deflate")

buildplugin(nczmisc "zmisc")
buildplugin(nczhdf5filters "zhdf5filters" netcdf)
buildplugin(nczstdfilters "zstdfilters" netcdf)

if(NETCDF_ENABLE_BLOSC)
set(h5blosc_SOURCES H5Zblosc.c)
buildplugin(h5blosc "h5blosc" netcdf;${Blosc_LIBRARIES})
buildplugin(h5blosc "h5blosc" ${Blosc_LIBRARIES})
buildplugin(nczstdfilters "zstdfilters" netcdf;${Blosc_LIBRARIES})
else()
buildplugin(nczstdfilters "zstdfilters" netcdf)
endif()

if(NETCDF_ENABLE_ZSTD)
set(h5zstd_SOURCES H5Zzstd.c H5Zzstd.h)
buildplugin(h5zstd "h5zstd" netcdf;${Zstd_LIBRARIES})
buildplugin(h5zstd "h5zstd" ${Zstd_LIBRARIES})
endif()

# Need our version of szip if libsz available and we are not using HDF5
Expand Down
Loading