Skip to content

Commit

Permalink
o Added NETCDF_ENABLE_PLUGINS option to cmake based build.
Browse files Browse the repository at this point in the history
o Added information related to plugins, plugin install location to post-build summary.
  • Loading branch information
WardF committed Aug 19, 2024
1 parent 71947c6 commit 5530997
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 22 deletions.
41 changes: 23 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -618,22 +618,26 @@ set(REMOTETESTSERVERS "remotetest.unidata.ucar.edu" CACHE STRING "test servers t
set(REMOTETESTSERVERS "remotetest.unidata.ucar.edu" CACHE STRING "test servers to use for remote test")

# Locate some compressors
option(NETCDF_ENABLE_PLUGINS "Enable netCDF Plugins." ON)
option(NETCDF_ENABLE_FILTER_SZIP "Enable use of Szip compression library if it is available. Required if NETCDF_ENABLE_NCZARR is true." ON)
option(NETCDF_ENABLE_FILTER_BZ2 "Enable use of Bz2 compression library if it is available." ON)
option(NETCDF_ENABLE_FILTER_BLOSC "Enable use of blosc compression library if it is available." ON)
option(NETCDF_ENABLE_FILTER_ZSTD "Enable use of Zstd compression library if it is available." ON)

# If user wants, then install selected plugins (default on)
set(PLUGIN_INSTALL_DIR "YES" CACHE STRING "Whether and where we should install plugins; defaults to yes")
set(NETCDF_PLUGIN_INSTALL_DIR "YES" CACHE STRING "Whether and where we should install plugins; defaults to yes")
if(NOT NETCDF_ENABLE_PLUGINS)
unset(NETCDF_PLUGIN_INSTALL_DIR CACHE)
endif()

# This is ugly, but seems necessary because of CMake's boolean structure
set(boolval FALSE)
if(DEFINED PLUGIN_INSTALL_DIR)
booleanize(${PLUGIN_INSTALL_DIR} boolval)
if(DEFINED NETCDF_PLUGIN_INSTALL_DIR)
booleanize(${NETCDF_PLUGIN_INSTALL_DIR} boolval)
if(boolval)
set(ENABLE_PLUGIN_INSTALL YES)
# No actual value was specified
unset(PLUGIN_INSTALL_DIR CACHE)
unset(NETCDF_PLUGIN_INSTALL_DIR CACHE)
else()
if(boolval STREQUAL "NOTFOUND")
# Must be an actual value
Expand All @@ -648,44 +652,44 @@ endif()

# Ensure no defined plugin dir if not enabled
if(NOT ENABLE_PLUGIN_INSTALL)
unset(PLUGIN_INSTALL_DIR CACHE)
unset(NETCDF_PLUGIN_INSTALL_DIR CACHE)
endif()

if(ENABLE_PLUGIN_INSTALL)
if(NOT DEFINED PLUGIN_INSTALL_DIR)
if(NOT DEFINED NETCDF_PLUGIN_INSTALL_DIR)
# Default to HDF5_PLUGIN_PATH or its default directories
if(DEFINED ENV{HDF5_PLUGIN_PATH})
set(PLUGIN_INSTALL_DIR "$ENV{HDF5_PLUGIN_PATH}")
set(NETCDF_PLUGIN_INSTALL_DIR "$ENV{HDF5_PLUGIN_PATH}")
else()
if(ISMSVC OR ISMINGW)
set(PLUGIN_INSTALL_DIR "$ENV{ALLUSERSPROFILE}\\hdf5\\lib\\plugin")
set(NETCDF_PLUGIN_INSTALL_DIR "$ENV{ALLUSERSPROFILE}\\hdf5\\lib\\plugin")
else()
set(PLUGIN_INSTALL_DIR "/usr/local/hdf5/lib/plugin")
set(NETCDF_PLUGIN_INSTALL_DIR "/usr/local/hdf5/lib/plugin")
endif()
endif()
message(STATUS "Defaulting to -DPLUGIN_INSTALL_DIR=${PLUGIN_INSTALL_DIR}")
message(STATUS "Defaulting to -DPLUGIN_INSTALL_DIR=${NETCDF_PLUGIN_INSTALL_DIR}")
endif()
endif()

if(ENABLE_PLUGIN_INSTALL)
# Use the lowest priority dir in the path
if(NOT ISMSVC AND NOT ISMINGW)
string(REPLACE ":" ";" PATH_LIST ${PLUGIN_INSTALL_DIR})
string(REPLACE ":" ";" PATH_LIST ${NETCDF_PLUGIN_INSTALL_DIR})
else()
set(PATH_LIST ${PLUGIN_INSTALL_DIR})
set(PATH_LIST ${NETCDF_PLUGIN_INSTALL_DIR})
endif()

# Get last element
list(GET PATH_LIST -1 PLUGIN_INSTALL_DIR)
set(PLUGIN_INSTALL_DIR_SETTING "${PLUGIN_INSTALL_DIR}")
message(STATUS "Final value of-DPLUGIN_INSTALL_DIR=${PLUGIN_INSTALL_DIR}")
list(GET PATH_LIST -1 NETCDF_PLUGIN_INSTALL_DIR)
set(PLUGIN_INSTALL_DIR_SETTING "${NETCDF_PLUGIN_INSTALL_DIR}")
message(STATUS "Final value of-DPLUGIN_INSTALL_DIR=${NETCDF_PLUGIN_INSTALL_DIR}")
else() # No option specified
unset(PLUGIN_INSTALL_DIR)
unset(PLUGIN_INSTALL_DIR CACHE)
unset(NETCDF_PLUGIN_INSTALL_DIR)
unset(NETCDF_PLUGIN_INSTALL_DIR CACHE)
set(PLUGIN_INSTALL_DIR_SETTING "N.A.")
endif()

message(STATUS "ENABLE_PLUGIN_INSTALL=${ENABLE_PLUGIN_INSTALL} PLUGIN_INSTALL_DIR=${PLUGIN_INSTALL_DIR}")
message(STATUS "ENABLE_PLUGIN_INSTALL=${ENABLE_PLUGIN_INSTALL} PLUGIN_INSTALL_DIR=${NETCDF_PLUGIN_INSTALL_DIR}")

# Try to enable NCZarr zip support
option(NETCDF_ENABLE_NCZARR_ZIP "Enable NCZarr ZIP support." ${NETCDF_ENABLE_NCZARR})
Expand Down Expand Up @@ -1698,6 +1702,7 @@ is_enabled(NETCDF_ENABLE_S3_INTERNAL HAS_S3_INTERNAL)
is_enabled(HAS_HDF5_ROS3 HAS_HDF5_ROS3)
is_enabled(NETCDF_ENABLE_NCZARR HAS_NCZARR)
is_enabled(NETCDF_ENABLE_NCZARR_ZIP HAS_NCZARR_ZIP)
is_enabled(NETCDF_ENABLE_PLUGINS HAS_PLUGINS)
is_enabled(NETCDF_ENABLE_QUANTIZE HAS_QUANTIZE)
is_enabled(NETCDF_ENABLE_LOGGING HAS_LOGGING)
is_enabled(NETCDF_ENABLE_FILTER_TESTING DO_FILTER_TESTS)
Expand Down
3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2035,6 +2035,7 @@ AC_SUBST(HAS_HDF5_ROS3,[$has_hdf5_ros3])
AC_SUBST(HAS_NCZARR,[$enable_nczarr])
AC_SUBST(NETCDF_ENABLE_S3_TESTING,[$with_s3_testing])
AC_SUBST(HAS_NCZARR_ZIP,[$enable_nczarr_zip])
AC_SUBST(HAS_PLUGINS, [$enable_plugins])
AC_SUBST(HAS_QUANTIZE,[$enable_quantize])
AC_SUBST(HAS_LOGGING,[$enable_logging])
AC_SUBST(DO_FILTER_TESTS,[$enable_filter_testing])
Expand Down Expand Up @@ -2142,7 +2143,7 @@ AM_CONDITIONAL([ENABLE_PLUGIN_DIR], [test "x$enable_plugin_dir" = xyes])
AC_SUBST([PLUGIN_INSTALL_DIR], [$with_plugin_dir])
# Better value for libnetcdf.settings
AC_SUBST([PLUGIN_INSTALL_DIR_SETTING], [$with_plugin_dir_setting])

AC_SUBST(NETCDF_PLUGIN_INSTALL_DIR, [$PLUGIN_INSTALL_DIR])
# Access netcdf specific version of config.h
AH_BOTTOM([#include "ncconfigure.h"])

Expand Down
3 changes: 3 additions & 0 deletions libnetcdf.settings.in
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ MMap Support: @HAS_MMAP@
ERANGE Fill Support: @HAS_ERANGE_FILL@
Relaxed Boundary Check: @RELAX_COORD_BOUND@

Plugins Enabled: @HAS_PLUGINS@
Plugin Install Dir: @NETCDF_PLUGIN_INSTALL_DIR@

Quantization: @HAS_QUANTIZE@
Logging: @HAS_LOGGING@
SZIP Write Support: @HAS_SZLIB_WRITE@
Expand Down
2 changes: 1 addition & 1 deletion nc-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ prefix="@CMAKE_INSTALL_PREFIX@"
exec_prefix="@CMAKE_INSTALL_PREFIX@"
libdir="@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@"
includedir="@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@"
plugindir="@PLUGIN_INSTALL_DIR@"
plugindir="@NETCDF_PLUGIN_INSTALL_DIR@"

cc="@CMAKE_C_COMPILER@"
cflags="-I@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@"
Expand Down
4 changes: 2 additions & 2 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ if(ENABLE_PLUGIN_INSTALL)

macro(installplugin PLUG)
set(INSTALLED_PLUGIN_LIB "${PLUGINPRE}${PLUG}.${PLUGINEXT}")
message(STATUS "Installing: ${INSTALLED_PLUGIN_LIB} into ${PLUGIN_INSTALL_DIR}")
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${INSTALLED_PLUGIN_LIB} DESTINATION ${PLUGIN_INSTALL_DIR})
message(STATUS "Installing: ${INSTALLED_PLUGIN_LIB} into ${NETCDF_PLUGIN_INSTALL_DIR}")
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${INSTALLED_PLUGIN_LIB} DESTINATION ${NETCDF_PLUGIN_INSTALL_DIR})
endmacro()

install(DIRECTORY DESTINATION ${PLUGIN_INSTALL_DIR})
Expand Down

0 comments on commit 5530997

Please sign in to comment.