improve the HDF4 version handling at configuration level.

This commit is contained in:
suter_a committed 2026-09-17 08:52:20 +02:00
1 parent 9a52b80600
commit 9da9e08153
1 file changed
+8 -1
+8 -1
View File
@@ -387,8 +387,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 ()