Skip to content

Commit

Permalink
Merge pull request #2722 from WardF/gh2712-parity.wif
Browse files Browse the repository at this point in the history
Enable/Disable some plugins at configure time
  • Loading branch information
WardF authored Jul 26, 2023
2 parents dac29bb + 4c71b59 commit 6e1895f
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 46 deletions.
44 changes: 32 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1110,31 +1110,51 @@ macro(set_std_filter filter)
# Upper case the filter name
string(TOUPPER "${filter}" upfilter)
string(TOLOWER "${filter}" downfilter)
if(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}")
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}")
ELSE()
SET(ENABLE_${upfilter} FALSE)
SET(HAVE_${upfilter} OFF)
ENDIF()
ELSE()
SET(ENABLE_${upfilter} FALSE)
SET(HAVE_${upfilter} OFF)
ENDIF()
endmacro(set_std_filter)

# Locate some compressors
FIND_PACKAGE(Szip)
FIND_PACKAGE(Bz2)
FIND_PACKAGE(Blosc)
FIND_PACKAGE(Zstd)
OPTION(ENABLE_FILTER_SZIP "Enable use of Szip compression library if it is available. Required if ENABLE_NCZARR is true." ON)
OPTION(ENABLE_FILTER_BZ2 "Enable use of Bz2 compression library if it is available." ON)
OPTION(ENABLE_FILTER_BLOSC "Enable use of blosc compression library if it is available." ON)
OPTION(ENABLE_FILTER_ZSTD "Enable use of Zstd compression library if it is available." ON)
IF (ENABLE_FILTER_SZIP)
FIND_PACKAGE(Szip)
ELSEIF(ENABLE_NCZARR)
FIND_PACKAGE(Szip)
ENDIF()
IF (ENABLE_FILTER_BZ2)
FIND_PACKAGE(Bz2)
ENDIF()
IF (ENABLE_FILTER_BLOSC)
FIND_PACKAGE(Blosc)
ENDIF()
IF (ENABLE_FILTER_ZSTD)
FIND_PACKAGE(Zstd)
ENDIF()

# Accumulate standard filters
set(STD_FILTERS "deflate") # Always have deflate*/
set_std_filter(Szip)
SET(HAVE_SZ ${Szip_FOUND})
SET(HAVE_SZ ${Szip_FOUND})
set_std_filter(Blosc)
IF(Zstd_FOUND)
set_std_filter(Zstd)
ENDIF()
IF(Bz2_FOUND)
set_std_filter(Bz2)
ELSE()
Expand Down
3 changes: 2 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ This file contains a high-level description of this package's evolution. Release

## 4.9.3 - TBD

* Fix memory leak WRT unreclaimed HDF5 plist. See [Github #????](https://github.com/Unidata/netcdf-c/pull/????).
* Introducing configure-time options to disable various filters, even if the required libraries are available on the system, in support of [GitHub #2712](https://github.com/Unidata/netcdf-c/pull/2712).
* Fix memory leak WRT unreclaimed HDF5 plist. See [Github #2752](https://github.com/Unidata/netcdf-c/pull/2752).
* Support HDF5 transient types when reading an HDF5 file. See [Github #2724](https://github.com/Unidata/netcdf-c/pull/2724).
* Suppress filters on variables with non-fixed-size types. See [Github #2716](https://github.com/Unidata/netcdf-c/pull/2716).
* Provide a single option to disable all network access and testing. See [Github #2708](https://github.com/Unidata/netcdf-c/pull/2708).
Expand Down
125 changes: 92 additions & 33 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -711,51 +711,110 @@ AM_CONDITIONAL(ENABLE_NCZARR, [test x$enable_nczarr = xyes])
# Look for Standardized libraries
##########

# See if we have libblosc
AC_CHECK_LIB([blosc],[blosc_init],[have_blosc=yes],[have_blosc=no])
if test "x$have_blosc" = "xyes" ; then
AC_SEARCH_LIBS([blosc_init],[blosc blosc.dll cygblosc.dll], [], [])
AC_DEFINE([HAVE_BLOSC], [1], [if true, blosc library is available])
##
# blosc checks
##

# See if we want to enable blosc, and if so, search for the library.
AC_MSG_CHECKING([whether to search for and enable blosc filter support])
AC_ARG_ENABLE([filter-blosc],
[AS_HELP_STRING([--disable-filter-blosc],
[disable blosc filter support.])])
test "x$enable_filter_blosc" = xno || enable_filter_blosc=yes
AC_MSG_RESULT($enable_filter_blosc)

if test "x$enable_filter_blosc" = "xyes" ; then
# See if we have libblosc
AC_CHECK_LIB([blosc],[blosc_init],[have_blosc=yes],[have_blosc=no])
if test "x$have_blosc" = "xyes" ; then
AC_SEARCH_LIBS([blosc_init],[blosc blosc.dll cygblosc.dll], [], [])
AC_DEFINE([HAVE_BLOSC], [1], [if true, blosc library is available])
fi
else
have_blosc=no
fi
##
# End blosc checks
##

# See if we have libzstd
AC_CHECK_LIB([zstd],[ZSTD_compress],[have_zstd=yes],[have_zstd=no])
if test "x$have_zstd" = "xyes" ; then
AC_SEARCH_LIBS([ZSTD_compress],[zstd zstd.dll cygzstd.dll], [], [])
AC_DEFINE([HAVE_ZSTD], [1], [if true, zstd library is available])
##
# libzstd checks
##

# See if we want to enable libzstd, and if so, search for the library.
AC_MSG_CHECKING([whether to search for and enable libzstd filter support])
AC_ARG_ENABLE([filter-zstd],
[AS_HELP_STRING([--disable-filter-zstd],
[disable zstd filter support.])])
test "x$enable_filter_zstd" = xno || enable_filter_zstd=yes
AC_MSG_RESULT($enable_filter_zstd)

if test "x$enable_filter_zstd" = "xyes" ; then
# See if we have libzstd
AC_CHECK_LIB([zstd],[ZSTD_compress],[have_zstd=yes],[have_zstd=no])
if test "x$have_zstd" = "xyes" ; then
AC_SEARCH_LIBS([ZSTD_compress],[zstd zstd.dll cygzstd.dll], [], [])
AC_DEFINE([HAVE_ZSTD], [1], [if true, zstd library is available])

fi
AC_MSG_CHECKING([whether libzstd library is available])
AC_MSG_RESULT([${have_zstd}])

##
# Ensure that the zstd.h dev files are also available.
##
if test "x$have_zstd" = "xyes" ; then
AC_CHECK_HEADERS([zstd.h], [], [nc_zstd_h_missing=yes])
if test "x$nc_zstd_h_missing" = xyes; then
AC_MSG_WARN([zstd library detected, but zstd.h development file not found. Ensure that the zstd development files are installed in order to build zstd support.])
AC_DEFINE([HAVE_ZSTD], [0], [if true, zstd library is available])
have_zstd=no
fi
fi

else
have_zstd=no
fi
AC_MSG_CHECKING([whether libzstd library is available])
AC_MSG_RESULT([${have_zstd}])
##
# End zstd checks
##

##
# Ensure that the zstd.h dev files are also available.
# Begin bz2 checks
##
if test "x$have_zstd" = "xyes" ; then
AC_CHECK_HEADERS([zstd.h], [], [nc_zstd_h_missing=yes])
if test "x$nc_zstd_h_missing" = xyes; then
AC_MSG_WARN([zstd library detected, but zstd.h development file not found. Ensure that the zstd development files are installed in order to build zstd support.])
AC_DEFINE([HAVE_ZSTD], [0], [if true, zstd library is available])
have_zstd=no

# See if we want to enable BZ2, and if so, search for the library.
AC_MSG_CHECKING([whether to search for and enable external bz2 filter support])
AC_ARG_ENABLE([filter-bz2],
[AS_HELP_STRING([--disable-filter-bz2],
[disable external bz2 filter support. bz2 support defaults to internal implementation if this is disabled or if the external library is not found.])])
test "x$enable_filter_bz2" = xno || enable_filter_bz2=yes
AC_MSG_RESULT($enable_filter_bz2)

if test "x$enable_filter_bz2" = "xyes" ; then

AC_CHECK_LIB([bz2],[BZ2_bzCompress],[have_bz2=yes],[have_bz2=no])
if test "x$have_bz2" = "xyes" ; then
AC_SEARCH_LIBS([BZ2_bzCompress],[bz2 bz2.dll cygbz2.dll], [], [])
AC_DEFINE([HAVE_BZ2], [1], [if true, bz2 library is installed])
fi
fi
AC_MSG_CHECKING([whether libbz2 library is available])
AC_MSG_RESULT([${have_bz2}])

# See if we have libbz2
AC_CHECK_LIB([bz2],[BZ2_bzCompress],[have_bz2=yes],[have_bz2=no])
if test "x$have_bz2" = "xyes" ; then
AC_SEARCH_LIBS([BZ2_bzCompress],[bz2 bz2.dll cygbz2.dll], [], [])
AC_DEFINE([HAVE_BZ2], [1], [if true, bz2 library is installed])
fi
AC_MSG_CHECKING([whether libbz2 library is available])
AC_MSG_RESULT([${have_bz2}])

if test "x$have_bz2" = "xno" ; then
have_local_bz2=yes
AC_MSG_NOTICE([Defaulting to internal libbz2])
else
have_local_bz2=no

if test "x$have_bz2" = "xno" ; then
have_local_bz2=yes
AC_MSG_NOTICE([Defaulting to internal libbz2])
else
have_local_bz2=no
fi
fi

AM_CONDITIONAL(HAVE_LOCAL_BZ2, [test "x$have_local_bz2" = xyes])
##
# End bz2 checks
##

# Note that szip management is tricky.
# This is because we have three things to consider:
Expand Down

0 comments on commit 6e1895f

Please sign in to comment.