Skip to content

Commit

Permalink
Merge pull request #2430 from DennisHeimbigner/cmakeplugin.dmh
Browse files Browse the repository at this point in the history
Fix the way CMake handles -DPLUGIN_INSTALL_DIR
  • Loading branch information
WardF authored Jul 6, 2022
2 parents a00bb62 + b2641a1 commit ee5e159
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 19 deletions.
72 changes: 56 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,27 @@ IF(${BIGENDIAN})
SET(WORDS_BIGENDIAN "1")
ENDIF(${BIGENDIAN})

# Define a function to convert various true or false values
# to either TRUE|FALSE (uppercase).
# If value is not a recognized boolean, then return NOTFOUND
#1, ON, YES, TRUE, Y,
#0, OFF, NO, FALSE, N, IGNORE, NOTFOUND -NOTFOUND ""

SET(TRUELIST "on;yes;y;true")
SET(FALSELIST "off;no;n;false;0;ignore;notfound")
function(booleanize VALUE RETVAR)
# force case
STRING(TOLOWER "${VALUE}" LCVALUE)
# Now do all the comparisons
if(LCVALUE IN_LIST TRUELIST OR LCVALUE GREATER 0)
SET(${RETVAR} TRUE PARENT_SCOPE)
elseif(LCVALUE IN_LIST FALSELIST OR LCVALUE MATCHES ".*-notfound" OR LCVALUE STREQUAL "")
SET(${RETVAR} FALSE PARENT_SCOPE)
else()
SET(${RETVAR} NOTFOUND PARENT_SCOPE)
endif()
endfunction()

# A macro to check if a C linker supports a particular flag.
MACRO(CHECK_C_LINKER_FLAG M_FLAG M_RESULT)
SET(T_REQ_FLAG "${CMAKE_REQUIRED_FLAGS}")
Expand Down Expand Up @@ -1120,41 +1141,60 @@ ENDIF()

# If user wants, then install selected plugins (default on)
SET(PLUGIN_INSTALL_DIR "NO" CACHE STRING "Whether and where we should install plugins; defaults to yes")
SET(ENABLE_PLUGIN_INSTALL NO)
IF(DEFINED PLUGIN_INSTALL_DIR) #OR DEFINED CACHE{PLUGIN_INSTALL_DIR}
STRING(TOLOWER "${PLUGIN_INSTALL_DIR}" LCPID)
IF(LCPID STREQUAL "no")
SET(ENABLE_PLUGIN_INSTALL NO)
ELSE()

# 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(boolval)
SET(ENABLE_PLUGIN_INSTALL YES)
# No actual value was specified
UNSET(PLUGIN_INSTALL_DIR CACHE)
ELSE()
IF(boolval STREQUAL "NOTFOUND")
# Must be an actual value
SET(ENABLE_PLUGIN_INSTALL YES)
ELSE()
SET(ENABLE_PLUGIN_INSTALL NO)
ENDIF()
ENDIF()
ELSE()
SET(ENABLE_PLUGIN_INSTALL NO)
ENDIF()

IF(ENABLE_PLUGIN_INSTALL AND PLUGIN_INSTALL_DIR STREQUAL "YES")
# Default to last dir (lowest search priority) in HDF5_PLUGIN_PATH
IF(DEFINED ENV{HDF5_PLUGIN_PATH})
SET(PLUGIN_PATH "$ENV{HDF5_PLUGIN_PATH}")
ELSE()
# Ensure no defined plugin dir if not enabled
IF(NOT ENABLE_PLUGIN_INSTALL)
UNSET(PLUGIN_INSTALL_DIR CACHE)
ENDIF()

IF(ENABLE_PLUGIN_INSTALL)
IF(NOT DEFINED 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}")
ELSE()
IF(ISMSVC OR ISMINGW)
SET(PLUGIN_PATH "$ENV{ALLUSERSPROFILE}\\hdf5\\lib\\plugin")
SET(PLUGIN_INSTALL_DIR "$ENV{ALLUSERSPROFILE}\\hdf5\\lib\\plugin")
ELSE()
SET(PLUGIN_PATH "/usr/local/hdf5/lib/plugin")
SET(PLUGIN_PLUGIN_DIR "/usr/local/hdf5/lib/plugin")
ENDIF()
ENDIF()
MESSAGE("Defaulting to -DPLUGIN_INSTALL_DIR=${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_PATH})
STRING(REPLACE ":" ";" PATH_LIST ${PLUGIN_INSTALL_DIR})
ELSE()
SET(PATH_LIST ${PLUGIN_PATH})
SET(PATH_LIST ${PLUGIN_INSTALL_DIR})
ENDIF()

# Get last element
LIST(GET PATH_LIST -1 PLUGIN_INSTALL_DIR)
MESSAGE("Defaulting to -DPLUGIN_INSTALL_DIR=${PLUGIN_INSTALL_DIR}")
SET(PLUGIN_INSTALL_DIR_SETTING "${PLUGIN_INSTALL_DIR}")
MESSAGE("Final value of-DPLUGIN_INSTALL_DIR=${PLUGIN_INSTALL_DIR}")
ELSE() # No option specified
UNSET(PLUGIN_INSTALL_DIR)
UNSET(PLUGIN_INSTALL_DIR CACHE)
Expand Down
6 changes: 3 additions & 3 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ Release Notes {#RELEASE_NOTES}

This file contains a high-level description of this package's evolution. Releases are in reverse chronological order (most recent first). Note that, as of netcdf 4.2, the `netcdf-c++` and `netcdf-fortran` libraries have been separated into their own libraries.


## 4.9.1 - T.B.D.

* [Enhancement] Add `--disable-quantize` option to `configure`.
* [Bug Fix] Fix CMakeLists.txt to handle all acceptable boolean values for -DPLUGIN_INSTALL_DIR. See [Github #2430](https://github.com/Unidata/netcdf-c/pull/2430).
* [Enhancement] Provide a simple API to allow user access to the internal .rc file table: supports get/set/overwrite of entries of the form "key=value". See [Github #2408](https://github.com/Unidata/netcdf-c/pull/2408).
* [Bug Fix] Use env variable USERPROFILE instead of HOME for windows and mingw. See [Github #2405](https://github.com/Unidata/netcdf-c/pull/2405).
* [Bug Fix] Fix the nc_def_var_fletcher32 code in hdf5 to properly test value of the fletcher32 argument. See [Github #2403](https://github.com/Unidata/netcdf-c/pull/2403).
Expand All @@ -23,6 +22,7 @@ This file contains a high-level description of this package's evolution. Release
* [Enhancement] Allow the read/write of JSON-valued Zarr attributes to allow
for domain specific info such as used by GDAL/Zarr. See [Github #2278](https://github.com/Unidata/netcdf-c/pull/2278).
* [Enhancement] Turn on the XArray convention for NCZarr files by default. WARNING, this means that the mode should explicitly specify "nczarr" or "zarr" even if "xarray" or "noxarray" is specified. See [Github #2257](https://github.com/Unidata/netcdf-c/pull/2257).

* [Enhancement] Update the documentation to match the current filter capabilities. See [Github #2249](https://github.com/Unidata/netcdf-c/pull/2249).
* [Enhancement] Support installation of pre-built standard filters into user-specified location. See [Github #2318](https://github.com/Unidata/netcdf-c/pull/2318).
* [Enhancement] Improve filter support. More specifically (1) add nc_inq_filter_avail to check if a filter is available, (2) add the notion of standard filters, (3) cleanup szip support to fix interaction with NCZarr. See [Github #2245](https://github.com/Unidata/netcdf-c/pull/2245).
Expand Down Expand Up @@ -193,7 +193,7 @@ See [GitHub #1251](https://github.com/Unidata/netcdf-c/issues/1251).
* Fix of --enable-benchmark benchmark tests [Github #1211](https://github.com/Unidata/netcdf-c/issues/1211)
* Update the license from the home-brewed NetCDF license to the standard 3-Clause BSD License. This change does not result in any new restrictions; it is merely the adoption of a standard, well-known and well-understood license in place of the historic NetCDF license written at Unidata. This is part of a broader push by Unidata to adopt modern, standardized licensing.
* [BugFix] Corrected DAP-related issues on big-endian machines. See [Github #1321](https://github.com/Unidata/netcdf-c/issues/1321), [Github #1302](https://github.com/Unidata/netcdf-c/issues/1302) for more information.
* [BugFix][Enhancement] Various and sundry bugfixes and performance enhancements, thanks to \@edhartnett, \@gsjaardema, \@t-b, \@wkliao, and all of our other contributors.
* [BugFix][Enhancement] Various and sundry bugfixes and performance enhancements, thanks to \@edhartnett, \@gsjarrdema, \@t-b, \@wkliao, and all of our other contributors.
* [Enhancement] Extended `nccopy -F` syntax to support multiple variables with a single invocation. See [Github #1311](https://github.com/Unidata/netcdf-c/issues/1311) for more information.
* [BugFix] Corrected an issue where DAP2 was incorrectly converting signed bytes, resulting in an erroneous error message under some circumstances. See [GitHub #1317](https://github.com/Unidata/netcdf-c/issues/1317) for more information. See [Github #1319](https://github.com/Unidata/netcdf-c/issues/1319) for related information.
* [BugFix][Enhancement] Modified `nccopy` so that `_NCProperties` is not copied over verbatim but is instead generated based on the version of `libnetcdf` used when copying the file. Additionally, `_NCProperties` are displayed if/when associated with a netcdf3 file, now. See [GitHub #803](https://github.com/Unidata/netcdf-c/issues/803) for more information.
Expand Down
1 change: 1 addition & 0 deletions nc_test4/tst_specific_filters.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh

set -x
set -e

if test "x$TESTNCZARR" = x1 ; then
Expand Down

0 comments on commit ee5e159

Please sign in to comment.