fixed cmake check for zlib in HDF5 library
@@ -751,16 +751,6 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
SET(HDF5_CC h5cc)
ENDIF()
- # Check to ensure that HDF5 was built with zlib.
- CHECK_C_SOURCE_COMPILES("#include <H5pubconf.h>
- int main() {#if !H5_HAVE_ZLIB_H
- #error
- #endif
- int x = 1;}" HAVE_HDF5_ZLIB)
- IF(NOT HAVE_HDF5_ZLIB)
- MESSAGE(FATAL_ERROR "HDF5 was built without zlib. Rebuild HDF5 with zlib.")
- ENDIF()
-
# Check to see if this is hdf5-1.10.3 or later.
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5Dread_chunk "" HDF5_SUPPORTS_PAR_FILTERS)
@@ -777,6 +767,18 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
INCLUDE_DIRECTORIES(${HAVE_HDF5_H})
ENDIF(NOT HAVE_HDF5_H)
+ # Check to ensure that HDF5 was built with zlib.
+ set (CMAKE_REQUIRED_INCLUDES ${HAVE_HDF5_H})
+ CHECK_C_SOURCE_COMPILES("#include <H5pubconf.h>
+ #if !H5_HAVE_ZLIB_H
+ #error
+ #endif
+ int main() {
+ int x = 1;}" HAVE_HDF5_ZLIB)
+ IF(NOT HAVE_HDF5_ZLIB)
+ MESSAGE(FATAL_ERROR "HDF5 was built without zlib. Rebuild HDF5 with zlib.")
+ ENDIF()
+
#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})
