summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--var/spack/repos/builtin/packages/hdf5/find_package_zlib.patch12
-rw-r--r--var/spack/repos/builtin/packages/hdf5/package.py6
2 files changed, 18 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/hdf5/find_package_zlib.patch b/var/spack/repos/builtin/packages/hdf5/find_package_zlib.patch
new file mode 100644
index 0000000000..73b65e826d
--- /dev/null
+++ b/var/spack/repos/builtin/packages/hdf5/find_package_zlib.patch
@@ -0,0 +1,12 @@
+diff --git a/CMakeFilters.cmake b/CMakeFilters.cmake
+index dbd68fd110..3d06b13d57 100644
+--- a/CMakeFilters.cmake
++++ b/CMakeFilters.cmake
+@@ -70,7 +70,6 @@ option (HDF5_ENABLE_Z_LIB_SUPPORT "Enable Zlib Filters" ON)
+ if (HDF5_ENABLE_Z_LIB_SUPPORT)
+ if (NOT H5_ZLIB_HEADER)
+ if (NOT ZLIB_USE_EXTERNAL)
+- find_package (ZLIB NAMES ${ZLIB_PACKAGE_NAME}${HDF_PACKAGE_EXT} COMPONENTS static shared)
+ if (NOT ZLIB_FOUND)
+ find_package (ZLIB) # Legacy find
+ endif ()
diff --git a/var/spack/repos/builtin/packages/hdf5/package.py b/var/spack/repos/builtin/packages/hdf5/package.py
index 112e1acb52..b4cef37ebf 100644
--- a/var/spack/repos/builtin/packages/hdf5/package.py
+++ b/var/spack/repos/builtin/packages/hdf5/package.py
@@ -164,6 +164,12 @@ class Hdf5(CMakePackage):
"+fortran", when="@1.13.3:^cmake@:3.22", msg="cmake_minimum_required is not set correctly."
)
+ # HDF5 searches for zlib CMake config files before it falls back to
+ # FindZLIB.cmake. We don't build zlib with CMake by default, so have to
+ # delete the first search, otherwise it may find a system zlib. See
+ # https://github.com/HDFGroup/hdf5/issues/4904
+ patch("find_package_zlib.patch", when="@1.8.16:")
+
# There are several officially unsupported combinations of the features:
# 1. Thread safety is not guaranteed via high-level C-API but in some cases
# it works.