Refactored the HDF5 version detection logic in CMakeLists.txt in support of https://github.com/Unidata/netcdf-c/issues/1962

This commit is contained in:
Ward Fisher 2021-04-01 11:24:11 -06:00
parent 5b40de1267
commit 17b4c2bebb

View File

@ -831,11 +831,20 @@ IF(USE_HDF5)
# Check to see if HDF5 library is 1.10.6 or greater.
# Used to control path name conversion
IF(${HDF5_VERSION} VERSION_LESS "1.10.6")
SET(HDF5_UTF8_PATHS FALSE)
ELSE()
SET(HDF5_UTF8_PATHS TRUE)
# Check HDF5 version
SET(HDF5_UT8_PATHS OFF)
CHECK_C_SOURCE_COMPILES("
#include <H5public.h>
int main() {
#if (H5_VERS_MAJOR*10000 + H5_VERS_MINOR*100 + H5_VERS_RELEASE < 11006)
choke me;
#endif
}" HDF5_VERSION_1106)
IF(HDF5_VERSION_1106)
SET(HDF5_UTF8_PATHS ON)
ENDIF()
MESSAGE("-- Checking for HDF5 version 1.10.6 or later: ${HDF5_UTF8_PATHS}")
SET(H5_USE_16_API 1)
@ -869,18 +878,6 @@ IF(USE_HDF5)
#option to include HDF5 High Level header file (hdf5_hl.h) in case we are not doing a make install
INCLUDE_DIRECTORIES(${HDF5_HL_INCLUDE_DIR})
# Check HDF5 version
CHECK_C_SOURCE_COMPILES("
#include <H5public.h>
int main() {
#if (H5_VERS_MAJOR*10000 + H5_VERS_MINOR*100 + H5_VERS_RELEASE < 11006)
choke me;
#endif
}" HDF5_VERSION_1106)
IF(HDF5_VERSION_1106)
SET(HDF5_UTF8_PATHS ON)
ENDIF()
ENDIF(USE_HDF5)