Skip to content

Commit 0921d30

Browse files
authored
Update libpng to 1.6.47 (#2733)
1 parent d7691bc commit 0921d30

File tree

5 files changed

+162
-28
lines changed

5 files changed

+162
-28
lines changed

.github/workflows/ci-windows.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,8 @@ jobs:
5757
CXX: clang-cl
5858

5959
- name: Prepare libavif (cmake)
60-
# CMake 4.0.0 removed compatibility with CMake < 3.5. Add
61-
# -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.
6260
run: >
6361
cmake -G Ninja -S . -B build
64-
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
6562
-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF
6663
-DAVIF_CODEC_AOM=LOCAL -DAVIF_CODEC_DAV1D=LOCAL
6764
-DAVIF_CODEC_RAV1E=LOCAL -DAVIF_CODEC_SVT=LOCAL

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The changes are relative to the previous release, unless the baseline is specifi
2020
* Update libsharpyuv: v1.5.0
2121
* Update libxml2.cmd/LocalLibXml2.cmake: v2.14.0
2222
* Update libyuv.cmd: dc47c71b3 (1907)
23+
* Update zlibpng.cmd: libpng 1.6.47
2324
* Fix wrong Exif orientation set in JPEG or PNG output by avifdec when the input
2425
AVIF file has an ImageRotation property with angle set to 1 or 3, has no
2526
ImageMirror property, and carries an Exif chunk. Note that Exif orientation is

cmake/Modules/LocalZlibpng.cmake

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# To upgrade libpng to > v1.6.40, you need zlib containing f1f503da85d52e56aae11557b4d79a42bcaa2b86
2-
# hence a version > v1.3.1 .
31
set(AVIF_ZLIB_GIT_TAG v1.3.1)
4-
set(AVIF_LIBPNG_GIT_TAG v1.6.40)
2+
set(AVIF_LIBPNG_GIT_TAG v1.6.47)
53

64
if(EXISTS "${AVIF_SOURCE_DIR}/ext/zlib")
75
message(STATUS "libavif(AVIF_ZLIBPNG=LOCAL): ext/zlib found; using as FetchContent SOURCE_DIR")
@@ -18,44 +16,29 @@ if(ANDROID_ABI)
1816
set(ZLIB_BINARY_DIR "${ZLIB_BINARY_DIR}/${ANDROID_ABI}")
1917
endif()
2018

19+
# The patch is taken from Google's or-tools
20+
# https://github.com/google/or-tools/blob/73bef34d95768a0fc0676023bd68111946deb417/cmake/dependencies/CMakeLists.txt
2121
FetchContent_Declare(
2222
zlib
2323
GIT_REPOSITORY "https://github.com/madler/zlib.git"
2424
SOURCE_DIR "${ZLIB_SOURCE_DIR}" BINARY_DIR "${ZLIB_BINARY_DIR}"
2525
GIT_TAG "${AVIF_ZLIB_GIT_TAG}"
2626
GIT_SHALLOW ON
27-
UPDATE_COMMAND ""
27+
UPDATE_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_SOURCE_DIR}/ext/zlib.patch"
2828
)
2929

3030
# Put the value of ZLIB_INCLUDE_DIR in the cache. This works around cmake behavior that has been updated by
3131
# cmake policy CMP0102 in cmake 3.17. Remove the CACHE workaround when we require cmake 3.17 or later. See
3232
# https://gitlab.kitware.com/cmake/cmake/-/issues/21343.
3333
set(ZLIB_INCLUDE_DIR "${ZLIB_SOURCE_DIR}" CACHE PATH "zlib include dir")
3434
set(ZLIB_BUILD_EXAMPLES OFF CACHE BOOL "")
35-
# This include_directories() call must be before add_subdirectory(ext/zlib) to work around the
36-
# zlib/CMakeLists.txt bug fixed by https://github.com/madler/zlib/pull/818.
37-
include_directories(SYSTEM $<BUILD_INTERFACE:${ZLIB_INCLUDE_DIR}>)
3835

3936
if(NOT zlib_POPULATED)
4037
avif_fetchcontent_populate_cmake(zlib)
4138
endif()
4239

43-
target_include_directories(zlibstatic INTERFACE $<BUILD_INTERFACE:${ZLIB_INCLUDE_DIR}>)
44-
45-
# This include_directories() call and the previous include_directories() call provide the zlib
46-
# include directories for add_subdirectory(ext/libpng). Because we set PNG_BUILD_ZLIB,
47-
# libpng/CMakeLists.txt won't call find_package(ZLIB REQUIRED) and will see an empty
48-
# ${ZLIB_INCLUDE_DIR}.
49-
include_directories("${zlib_BINARY_DIR}")
5040
set(CMAKE_DEBUG_POSTFIX "")
5141

52-
add_library(ZLIB::ZLIB ALIAS zlibstatic)
53-
54-
# TODO Uncomment for zlib > v1.3
55-
# install(TARGETS zlib zlibstatic EXPORT zlib)
56-
# install(EXPORT zlib
57-
# DESTINATION ${CMAKE_INSTALL_LIBDIR}/zlib)
58-
5942
message(CHECK_PASS "complete")
6043

6144
if(EXISTS "${AVIF_SOURCE_DIR}/ext/libpng")
@@ -69,10 +52,12 @@ endif()
6952
# This is the only way I could avoid libpng going crazy if it found awk.exe, seems benign otherwise
7053
set(PREV_ANDROID ${ANDROID})
7154
set(ANDROID TRUE)
72-
set(PNG_BUILD_ZLIB "${zlib_SOURCE_DIR}" CACHE STRING "" FORCE)
55+
set(ZLIB_LIBRARY ZLIB)
56+
set(ZLIB_ROOT "${zlib_SOURCE_DIR}" CACHE STRING "" FORCE)
57+
set(ZLIB_USE_STATIC_LIBS ON CACHE BOOL "")
7358
set(PNG_SHARED OFF CACHE BOOL "")
7459
set(PNG_TESTS OFF CACHE BOOL "")
75-
set(PNG_EXECUTABLES OFF CACHE BOOL "")
60+
set(PNG_TOOLS OFF CACHE BOOL "")
7661

7762
set(LIBPNG_BINARY_DIR "${FETCHCONTENT_BASE_DIR}/libpng")
7863
if(ANDROID_ABI)
@@ -94,7 +79,7 @@ set(PNG_PNG_INCLUDE_DIR "${libpng_SOURCE_DIR}")
9479
include_directories("${libpng_BINARY_DIR}")
9580
set(ANDROID ${PREV_ANDROID})
9681

97-
set_target_properties(png_static zlibstatic PROPERTIES AVIF_LOCAL ON)
82+
set_target_properties(png_static ZLIB PROPERTIES AVIF_LOCAL ON)
9883
add_library(PNG::PNG ALIAS png_static)
9984

10085
message(CHECK_PASS "complete")

ext/zlib.patch

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 15ceebe..03825a2 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -1,23 +1,21 @@
6+
-cmake_minimum_required(VERSION 2.4.4...3.15.0)
7+
-set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
8+
+cmake_minimum_required(VERSION 3.15)
9+
10+
-project(zlib C)
11+
-
12+
-set(VERSION "1.3.1")
13+
+project(zlib VERSION 1.3.1 LANGUAGES C)
14+
15+
option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" ON)
16+
17+
-set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
18+
-set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
19+
-set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
20+
-set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages")
21+
-set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
22+
+include(GNUInstallDirs)
23+
+set(INSTALL_BIN_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH "Installation directory for executables")
24+
+set(INSTALL_LIB_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Installation directory for libraries")
25+
+set(INSTALL_INC_DIR "${CMAKE_INSTALL_INCLUDEDIR}" CACHE PATH "Installation directory for headers")
26+
+set(INSTALL_MAN_DIR "${CMAKE_INSTALL_MANDIR}" CACHE PATH "Installation directory for manual pages")
27+
+set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_DATADIR}/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
28+
29+
include(CheckTypeSize)
30+
include(CheckFunctionExists)
31+
include(CheckIncludeFile)
32+
include(CheckCSourceCompiles)
33+
-enable_testing()
34+
+include(CTest)
35+
36+
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
37+
check_include_file(stdint.h HAVE_STDINT_H)
38+
@@ -149,12 +147,21 @@ if(MINGW)
39+
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
40+
endif(MINGW)
41+
42+
-add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
43+
-target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
44+
-add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
45+
-target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
46+
-set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
47+
-set_target_properties(zlib PROPERTIES SOVERSION 1)
48+
+if(BUILD_SHARED_LIBS)
49+
+ add_library(ZLIB SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
50+
+ set_target_properties(ZLIB PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
51+
+ set_target_properties(ZLIB PROPERTIES SOVERSION 1)
52+
+else()
53+
+ add_library(ZLIB STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
54+
+endif()
55+
+
56+
+target_include_directories(ZLIB PUBLIC
57+
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
58+
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
59+
+ $<INSTALL_INTERFACE:include>)
60+
+
61+
+add_library(ZLIB::ZLIB ALIAS ZLIB)
62+
+
63+
64+
if(NOT CYGWIN)
65+
# This property causes shared libraries on Linux to have the full version
66+
@@ -164,26 +171,49 @@ if(NOT CYGWIN)
67+
#
68+
# This has no effect with MSVC, on that platform the version info for
69+
# the DLL comes from the resource file win32/zlib1.rc
70+
- set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
71+
+ set_target_properties(ZLIB PROPERTIES VERSION ${ZLIB_FULL_VERSION})
72+
endif()
73+
74+
if(UNIX)
75+
# On unix-like platforms the library is almost always called libz
76+
- set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
77+
- if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
78+
- set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
79+
+ set_target_properties(ZLIB PROPERTIES OUTPUT_NAME z)
80+
+ if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX) AND BUILD_SHARED_LIBS)
81+
+ set_target_properties(ZLIB PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
82+
endif()
83+
elseif(BUILD_SHARED_LIBS AND WIN32)
84+
# Creates zlib1.dll when building shared library version
85+
- set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
86+
+ set_target_properties(ZLIB PROPERTIES SUFFIX "1.dll")
87+
+endif()
88+
+
89+
+if(NOT UNIX)
90+
+ if(BUILD_SHARED_LIBS)
91+
+ set_target_properties(ZLIB PROPERTIES OUTPUT_NAME zlib)
92+
+ else()
93+
+ set_target_properties(ZLIB PROPERTIES OUTPUT_NAME zlibstatic)
94+
+ endif()
95+
endif()
96+
97+
-if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
98+
- install(TARGETS zlib zlibstatic
99+
- RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
100+
- ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
101+
- LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
102+
+if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
103+
+ install(TARGETS ZLIB
104+
+ EXPORT ZLIBTargets
105+
+ RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
106+
+ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
107+
+ LIBRARY DESTINATION "${INSTALL_LIB_DIR}")
108+
+ install(EXPORT ZLIBTargets
109+
+ NAMESPACE ZLIB::
110+
+ DESTINATION lib/cmake/ZLIB)
111+
+ include(CMakePackageConfigHelpers)
112+
+ write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/ZLIBConfigVersion.cmake"
113+
+ VERSION ${PROJECT_VERSION}
114+
+ COMPATIBILITY SameMajorVersion)
115+
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ZLIBConfig.cmake"
116+
+ "include(\"\${CMAKE_CURRENT_LIST_DIR}/ZLIBTargets.cmake\")"
117+
+ )
118+
+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ZLIBConfig.cmake"
119+
+ "${CMAKE_CURRENT_BINARY_DIR}/ZLIBConfigVersion.cmake"
120+
+ DESTINATION lib/cmake/ZLIB)
121+
endif()
122+
+
123+
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
124+
install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}")
125+
endif()
126+
@@ -199,20 +229,20 @@ endif()
127+
#============================================================================
128+
if(ZLIB_BUILD_EXAMPLES)
129+
add_executable(example test/example.c)
130+
- target_link_libraries(example zlib)
131+
+ target_link_libraries(example ZLIB)
132+
add_test(example example)
133+
134+
add_executable(minigzip test/minigzip.c)
135+
- target_link_libraries(minigzip zlib)
136+
+ target_link_libraries(minigzip ZLIB)
137+
138+
if(HAVE_OFF64_T)
139+
add_executable(example64 test/example.c)
140+
- target_link_libraries(example64 zlib)
141+
+ target_link_libraries(example64 ZLIB)
142+
set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
143+
add_test(example64 example64)
144+
145+
add_executable(minigzip64 test/minigzip.c)
146+
- target_link_libraries(minigzip64 zlib)
147+
+ target_link_libraries(minigzip64 ZLIB)
148+
set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
149+
endif()
150+
endif()

ext/zlibpng.cmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
: # The odd choice of comment style in this file is to try to share this script between *nix and win32.
66

77
git clone -b v1.3.1 --depth 1 https://github.com/madler/zlib.git
8-
git clone -b v1.6.40 --depth 1 https://github.com/glennrp/libpng.git
8+
git apply --ignore-whitespace
9+
git clone -b v1.6.47 --depth 1 https://github.com/glennrp/libpng.git

0 commit comments

Comments
 (0)