Skip to content

Commit 592edbd

Browse files
iscgarruevs
authored andcommitted
extlib: update libpng to v1.6.50
This solves an issue with CMake 4.0.0, which doesn't support configs for versions earlier than 3.5. This unfortunately also requires messing with the way we include zlib, because the static libpng target isn't really compatible with the way zlib is built.
1 parent b9a9e26 commit 592edbd

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

CMakeLists.txt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,22 @@ if(ENABLE_GUI OR ENABLE_CLI)
243243
set(FORCE_VENDORED_PNG ON)
244244
set(FORCE_VENDORED_Freetype ON)
245245

246-
find_vendored_package(ZLIB zlib
247-
ZLIB_LIBRARY zlibstatic
248-
ZLIB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extlib/zlib)
246+
# HACK: This is essentially what `find_vendored_package()` does, except we also
247+
# define the ZLIB::ZLIB target to be an alias for zlibstatic before calling
248+
# `find_package()` in order to avoid having it defined as an imported target
249+
# by the built-in FindZLIB.cmake module, which breaks libpng's png_static
250+
# target that relies on ZLIB::ZLIB instead of on zlibstatic.
251+
# Once zlib releases its develop branch post 1.3.1, the built-in module will not
252+
# generate an imported target since we'll have proper targets, but libpng would
253+
# still need to be updated to use ZLIB::ZLIBSTATIC instead of ZLIB::ZLIB, so this
254+
# ugly hack will have to stay until both libraries release fixed versions.
255+
add_vendored_subdirectory(extlib/zlib)
256+
set(ZLIB_LIBRARY zlibstatic CACHE INTERNAL "")
257+
set(ZLIB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extlib/zlib CACHE INTERNAL "")
258+
add_library(ZLIB::ZLIB ALIAS ${ZLIB_LIBRARY})
259+
find_package(ZLIB REQUIRED)
260+
set(ZLIB_FOUND ${ZLIB_FOUND} CACHE INTERNAL "")
261+
249262
list(APPEND ZLIB_INCLUDE_DIR ${CMAKE_BINARY_DIR}/extlib/zlib)
250263

251264
# There's an issue with the zlib configuration, which doesn't provide a way to
@@ -266,10 +279,9 @@ if(ENABLE_GUI OR ENABLE_CLI)
266279
find_vendored_package(PNG libpng
267280
SKIP_INSTALL_ALL ON
268281
PNG_LIBRARY png_static
269-
PNG_ARM_NEON "off"
270282
PNG_SHARED OFF
271283
PNG_STATIC ON
272-
PNG_EXECUTABLES OFF
284+
PNG_TOOLS OFF
273285
PNG_TESTS OFF
274286
PNG_FRAMEWORK OFF
275287
PNG_PNG_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extlib/libpng)

extlib/libpng

0 commit comments

Comments
 (0)