From 17b4c2bebb6ba634b9b2ef270c19fe792c6081dc Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Thu, 1 Apr 2021 11:24:11 -0600 Subject: [PATCH] Refactored the HDF5 version detection logic in CMakeLists.txt in support of https://github.com/Unidata/netcdf-c/issues/1962 --- CMakeLists.txt | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 22c88bb0e..76b5b2814 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 + 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 - 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)