Skip to content

Commit 3d812e5

Browse files
author
James Sharpe
authored
Update zlib version (#1413)
1 parent fe84b67 commit 3d812e5

File tree

2 files changed

+60
-15
lines changed

2 files changed

+60
-15
lines changed
Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,81 @@
1-
--- CMakeLists.txt 2022-10-13 06:06:55.000000000 +0100
2-
+++ CMakeLists.txt 2022-10-13 06:06:55.000000000 +0100
3-
@@ -147,8 +147,7 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 15ceebe..2f08574 100644
3+
--- CMakeLists.txt
4+
+++ CMakeLists.txt
5+
@@ -59,7 +59,6 @@ endif()
6+
check_include_file(unistd.h Z_HAVE_UNISTD_H)
7+
8+
if(MSVC)
9+
- set(CMAKE_DEBUG_POSTFIX "d")
10+
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
11+
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
12+
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
13+
@@ -122,7 +121,7 @@ set(ZLIB_SRCS
14+
zutil.c
15+
)
16+
17+
-if(NOT MINGW)
18+
+if(MSVC)
19+
set(ZLIB_DLL_SRCS
20+
win32/zlib1.rc # If present will override custom build rule below.
21+
)
22+
@@ -133,7 +132,7 @@ file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
23+
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
24+
"\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
25+
26+
-if(MINGW)
27+
+if(WIN32 AND NOT MSVC)
28+
# This gets us DLL resource information when compiling on MinGW.
29+
if(NOT CMAKE_RC_COMPILER)
30+
set(CMAKE_RC_COMPILER windres.exe)
31+
@@ -147,14 +146,16 @@ if(MINGW)
32+
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
33+
-i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
434
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
5-
endif(MINGW)
35+
-endif(MINGW)
36+
+endif()
637

7-
-add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
38+
+if(BUILD_SHARED_LIBS)
39+
add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
40+
target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
841
-add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
9-
+add_library(zlib ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
42+
-target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
1043
set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
1144
set_target_properties(zlib PROPERTIES SOVERSION 1)
45+
+else()
46+
+add_library(zlib STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
47+
+endif()
1248

13-
@@ -163,19 +162,18 @@
49+
if(NOT CYGWIN)
50+
# This property causes shared libraries on Linux to have the full version
51+
@@ -167,19 +168,25 @@ if(NOT CYGWIN)
1452
set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
1553
endif()
1654

1755
-if(UNIX)
56+
+if(WIN32 AND NOT MINGW)
57+
+ if(BUILD_SHARED_LIBS)
58+
+ set_target_properties(zlib PROPERTIES ARCHIVE_OUTPUT_NAME zdll)
59+
+ endif()
60+
+else()
1861
# On unix-like platforms the library is almost always called libz
1962
- set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
20-
- if(NOT APPLE)
2163
+ set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
22-
+ if(UNIX AND NOT APPLE)
64+
if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
2365
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
2466
endif()
2567
-elseif(BUILD_SHARED_LIBS AND WIN32)
68+
+endif()
2669
+if(BUILD_SHARED_LIBS AND WIN32)
2770
# Creates zlib1.dll when building shared library version
28-
set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
71+
- set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
72+
+ set_target_properties(zlib PROPERTIES PREFIX "" RUNTIME_OUTPUT_NAME "zlib1")
2973
endif()
3074

75+
+
3176
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
3277
- install(TARGETS zlib zlibstatic
3378
+ install(TARGETS zlib
3479
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
3580
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
36-
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
81+
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )

examples/third_party/zlib/zlib_repositories.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ def zlib_repositories():
88
http_archive,
99
name = "zlib",
1010
build_file = Label("//zlib:BUILD.zlib.bazel"),
11-
sha256 = "b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30",
12-
strip_prefix = "zlib-1.2.13",
11+
sha256 = "9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23",
12+
strip_prefix = "zlib-1.3.1",
1313
patches = [
1414
# This patch modifies zlib so that on windows the generated lib matches that stated in the generated pkgconfig pc file for consumption by dependent rules
1515
# Similar patches are used in vcpkg and conan to resolve the same issue
1616
Label("//zlib:zlib.patch"),
1717
],
1818
urls = [
19-
"https://zlib.net/zlib-1.2.13.tar.gz",
20-
"https://storage.googleapis.com/mirror.tensorflow.org/zlib.net/zlib-1.2.13.tar.gz",
19+
"https://zlib.net/zlib-1.3.1.tar.gz",
20+
"https://zlib.net/archive/zlib-1.3.1.tar.gz",
2121
],
2222
)

0 commit comments

Comments
 (0)