diff --git a/CMakeLists.txt b/CMakeLists.txt index 5dcf8c28..e5e7290b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -349,6 +349,12 @@ if (nexus) message(FATAL_ERROR "HDF4 library not found. Please install libhdf4-dev or hdf-devel") endif() + #--- try to extract the HDF4 version from H4config.h (autotools builds) -------- + if (EXISTS "${HDF4_INCLUDE_DIR}/H4config.h") + file(STRINGS "${HDF4_INCLUDE_DIR}/H4config.h" HDF4_VERSION_LINE REGEX "^#define[ \t]+H4_VERSION[ \t]+\"[^\"]*\"") + string(REGEX REPLACE "^#define[ \t]+H4_VERSION[ \t]+\"([^\"]*)\".*" "\\1" HDF4_VERSION "${HDF4_VERSION_LINE}") + endif () + # HDF4 4.4.0 changed the Vgetname() prototype from # int32 Vgetname(int32 vkey, char *vgname) # to @@ -497,7 +503,7 @@ endif (OpenMP_FOUND) if (nexus) message("") if (HAVE_HDF4) - message(" HDF4 found in ${HDF4_INCLUDE_DIRS}") + message(" HDF4 found in ${HDF4_INCLUDE_DIRS}, Version: ${HDF4_VERSION}") else (HAVE_HDF4) message(" HDF4 not present.") endif (HAVE_HDF4)