Skip to content

Commit 8177888

Browse files
committed
add -Dzlib_legacy:BOOL option for Zlib 1.x fallback (default 2.x)
1 parent 953bf8b commit 8177888

File tree

6 files changed

+27
-6
lines changed

6 files changed

+27
-6
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ set FC=ifort
9898
This is necessary to workaround techniques used by HDF5 CMake files that don't pickup the CMake `set(ENV{CC})`.
9999
Otherwise, HDF5 build failures may result due to defaulting to icl-clang.
100100

101+
By default we use Zlib 2.x a.k.a. zlib-ng.
102+
If you have a problem with Zlib-ng on your system, try the unmaintained Zlib 1.x by:
103+
104+
```sh
105+
cmake -B build -Dzlib_legacy=on
106+
```
107+
101108
## Usage
102109

103110
The simplest [example](./Examples/) h5fortran usage is like:

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.7.1
1+
3.7.2

cmake/build_zlib.cmake

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
include(ExternalProject)
44

55
if(WIN32)
6-
set(ZLIB_name ${CMAKE_STATIC_LIBRARY_PREFIX}zlib${CMAKE_STATIC_LIBRARY_SUFFIX})
6+
if(zlib_legacy)
7+
set(ZLIB_name ${CMAKE_STATIC_LIBRARY_PREFIX}zlibstatic${CMAKE_STATIC_LIBRARY_SUFFIX})
8+
else()
9+
set(ZLIB_name ${CMAKE_STATIC_LIBRARY_PREFIX}zlib${CMAKE_STATIC_LIBRARY_SUFFIX})
10+
endif()
711
else()
812
set(ZLIB_name ${CMAKE_STATIC_LIBRARY_PREFIX}z${CMAKE_STATIC_LIBRARY_SUFFIX})
913
endif()
@@ -24,7 +28,7 @@ ExternalProject_Add(ZLIB
2428
URL ${zlib_url}
2529
URL_HASH SHA256=${zlib_sha256}
2630
CONFIGURE_HANDLED_BY_BUILD ON
27-
INACTIVITY_TIMEOUT 30
31+
INACTIVITY_TIMEOUT 15
2832
CMAKE_ARGS -DZLIB_COMPAT:BOOL=on -DZLIB_ENABLE_TESTS:BOOL=off -DBUILD_SHARED_LIBS:BOOL=off -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=${ZLIB_ROOT}
2933
BUILD_BYPRODUCTS ${ZLIB_LIBRARY}
3034
)

cmake/libraries.cmake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ else()
99
# CMake >= 3.19
1010
file(READ ${CMAKE_CURRENT_LIST_DIR}/libraries.json _libj)
1111

12-
string(JSON zlib_url GET ${_libj} zlib url)
13-
string(JSON zlib_sha256 GET ${_libj} zlib sha256)
12+
if(zlib_legacy)
13+
string(JSON zlib_url GET ${_libj} zlib1 url)
14+
string(JSON zlib_sha256 GET ${_libj} zlib1 sha256)
15+
else()
16+
string(JSON zlib_url GET ${_libj} zlib2 url)
17+
string(JSON zlib_sha256 GET ${_libj} zlib2 sha256)
18+
endif()
1419

1520
string(JSON hdf5_url GET ${_libj} hdf5 url)
1621
string(JSON hdf5_sha256 GET ${_libj} hdf5 sha256)

cmake/libraries.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"url": "https://zlib.net/zlib1211.zip",
44
"sha256": "d7510a8ee1918b7d0cad197a089c0a2cd4d6df05fee22389f67f115e738b178d"
55
},
6-
"zlib": {
6+
"zlib2": {
77
"url" : "https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.0.2.zip",
88
"sha256": "58a86813746ac1e2354244b1e01f22d8b4814c69e7a8fca14c657d13f67bb5bc"
99
},

cmake/options.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ option(shaky "run shaky tests that may segfault since designed to fail" off)
66
option(matlab "check HDF5 file writes with Matlab" off)
77
option(concepts "conceptual testing, for devs only" off)
88

9+
option(zlib_legacy "use unmaintained ZLIB 1.x")
10+
if(zlib_legacy AND CMAKE_VERSION VERSION_LESS 3.19)
11+
message(FATAL_ERROR "Zlib 1.x requires CMake >= 3.19")
12+
endif()
13+
914
set(CMAKE_EXPORT_COMPILE_COMMANDS true)
1015

1116
set(CMAKE_TLS_VERIFY true)

0 commit comments

Comments
 (0)