Skip to content

Commit 07e37ba

Browse files
committed
Make zlib static
1 parent 5a25203 commit 07e37ba

File tree

3 files changed

+58
-10
lines changed

3 files changed

+58
-10
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ run-name: Test ${{inputs.ref_name||github.ref_name}}
88

99
on:
1010
push:
11+
branches-ignore: main
1112
workflow_dispatch:
1213
inputs:
1314
ref_name:

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ fi
8383

8484
./build-make-dep.sh nv-codec-headers
8585

86-
CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ./build-cmake-dep.sh zlib
86+
./build-cmake-dep.sh zlib -DZLIB_BUILD_EXAMPLES=OFF
8787
add_ffargs "--enable-zlib"
8888

8989
if [ -n "$ENABLE_LIBFREETYPE" ]; then

patches/zlib.patch

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,60 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 15ceebe..303f5d6 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -149,12 +149,16 @@ if(MINGW)
6+
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
7+
endif(MINGW)
8+
9+
-add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
10+
-target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
11+
-add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
12+
-target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
13+
-set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
14+
-set_target_properties(zlib PROPERTIES SOVERSION 1)
15+
+if(BUILD_SHARED_LIBS)
16+
+ add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
17+
+ target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
18+
+ set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
19+
+ set_target_properties(zlib PROPERTIES SOVERSION 1)
20+
+else()
21+
+ add_library(zlib STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
22+
+ target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
23+
+endif()
24+
+
25+
26+
if(NOT CYGWIN)
27+
# This property causes shared libraries on Linux to have the full version
28+
@@ -169,7 +173,7 @@ endif()
29+
30+
if(UNIX)
31+
# On unix-like platforms the library is almost always called libz
32+
- set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
33+
+ set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
34+
if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
35+
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
36+
endif()
37+
@@ -179,7 +183,7 @@ elseif(BUILD_SHARED_LIBS AND WIN32)
38+
endif()
39+
40+
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
41+
- install(TARGETS zlib zlibstatic
42+
+ install(TARGETS zlib
43+
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
44+
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
45+
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
146
diff --git a/zconf.h.cmakein b/zconf.h.cmakein
2-
index 0abe3bc..5b9ccdf 100644
47+
index 0abe3bc..53e028c 100644
348
--- a/zconf.h.cmakein
449
+++ b/zconf.h.cmakein
5-
@@ -483,7 +483,7 @@ typedef uLong FAR uLongf;
50+
@@ -436,7 +436,9 @@ typedef uLong FAR uLongf;
651
#endif
7-
#ifndef Z_SOLO
8-
# if defined(Z_HAVE_UNISTD_H)
9-
-# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
10-
+// # include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
11-
# ifdef VMS
12-
# include <unixio.h> /* for off_t */
13-
# endif
52+
53+
#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
54+
-# define Z_HAVE_UNISTD_H
55+
+# if Z_HAVE_UNISTD_H != 0
56+
+# define Z_HAVE_UNISTD_H
57+
+# endif
58+
#endif
59+
60+
#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */

0 commit comments

Comments
 (0)