improve the HDF4 version handling at configuration level.

This commit is contained in:
suter_a committed 2026-09-17 08:48:41 +02:00
1 parent 40b0ec98fc
commit 5cd7bd232c
1 file changed
+8 -1
+8 -1
View File
@@ -357,8 +357,15 @@ if (nexus)
endif()
#--- try to extract the HDF4 version from H4config.h (autotools builds) --------
# Some distributions (e.g. Debian/Ubuntu's libhdf4-dev) install it lower-cased
# as 'h4config.h' instead of the upstream 'H4config.h', so check both.
if (EXISTS "${HDF4_INCLUDE_DIR}/H4config.h")
file(STRINGS "${HDF4_INCLUDE_DIR}/H4config.h" HDF4_VERSION_LINE REGEX "^#define[ \t]+H4_VERSION[ \t]+\"[^\"]*\"")
set(HDF4_CONFIG_HEADER "${HDF4_INCLUDE_DIR}/H4config.h")
elseif (EXISTS "${HDF4_INCLUDE_DIR}/h4config.h")
set(HDF4_CONFIG_HEADER "${HDF4_INCLUDE_DIR}/h4config.h")
endif ()
if (HDF4_CONFIG_HEADER)
file(STRINGS "${HDF4_CONFIG_HEADER}" HDF4_VERSION_LINE REGEX "^#define[ \t]+H4_VERSION[ \t]+\"[^\"]*\"")
string(REGEX REPLACE "^#define[ \t]+H4_VERSION[ \t]+\"([^\"]*)\".*" "\\1" HDF4_VERSION "${HDF4_VERSION_LINE}")
endif ()