hdf5: use spack installed zlib (#46612)

Avoid that hdf5 searches all search paths for ZLIB.cmake config files (inluding /usr/lib), before it looks for zlib without cmake config files, which is how Spack installs it
This commit is contained in:
Satish Balay 2024-10-04 14:55:46 -05:00 committed by GitHub
parent 8f798c01ec
commit be21b0b3bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 0 deletions

View File

@ -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 ()

View File

@ -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.