From 55309972e89746ec6c5fc1634995503c71e8e967 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Mon, 19 Aug 2024 13:47:00 -0600 Subject: [PATCH] o Added NETCDF_ENABLE_PLUGINS option to cmake based build. o Added information related to plugins, plugin install location to post-build summary. --- CMakeLists.txt | 41 +++++++++++++++++++++++------------------ configure.ac | 3 ++- libnetcdf.settings.in | 3 +++ nc-config.cmake.in | 2 +- plugins/CMakeLists.txt | 4 ++-- 5 files changed, 31 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e8749a0596..1622f6a686 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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}) @@ -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) diff --git a/configure.ac b/configure.ac index 9f5238d13b..6ed7fdd05d 100644 --- a/configure.ac +++ b/configure.ac @@ -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]) @@ -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"]) diff --git a/libnetcdf.settings.in b/libnetcdf.settings.in index d459aa714a..4cf899a47b 100644 --- a/libnetcdf.settings.in +++ b/libnetcdf.settings.in @@ -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@ diff --git a/nc-config.cmake.in b/nc-config.cmake.in index 5eda94d20c..121f996f02 100644 --- a/nc-config.cmake.in +++ b/nc-config.cmake.in @@ -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@" diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 0912cd824e..09ccf4b943 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -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})