Skip to content

Commit

Permalink
Get libpng build to work with ZLIBConfig.cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
starseeker committed Oct 11, 2024
1 parent 09a61a0 commit d350f63
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 216 deletions.
3 changes: 2 additions & 1 deletion png/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ if (ENABLE_PNG)
ExternalProject_Add(PNG_BLD
URL "${CMAKE_CURRENT_SOURCE_DIR}/libpng"
BUILD_ALWAYS ${EXT_BUILD_ALWAYS} ${LOG_OPTS}
PATCH_COMMAND ${PATCH_EXECUTABLE};-E;-p1;${PATCH_OPTIONS};-i;${CMAKE_CURRENT_SOURCE_DIR}/png.patch
PATCH_COMMAND ${PATCH_EXECUTABLE};-E;-p1;${PATCH_OPTIONS};-i;${CMAKE_CURRENT_SOURCE_DIR}/png_cmake.patch
COMMAND ${PATCH_EXECUTABLE};-E;-p1;${PATCH_OPTIONS};-i;${CMAKE_CURRENT_SOURCE_DIR}/png_zlib.patch
CMAKE_ARGS
-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON
${BUILD_TYPE_SPECIFIER}
Expand Down
215 changes: 0 additions & 215 deletions png/png.patch

This file was deleted.

70 changes: 70 additions & 0 deletions png/png_cmake.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
diff -Naur libpng/CMakeLists.txt PNG_BLD/CMakeLists.txt
--- libpng/CMakeLists.txt 2024-10-11 10:39:06.421433191 -0400
+++ PNG_BLD/CMakeLists.txt 2024-10-11 10:40:45.921699021 -0400
@@ -47,8 +47,10 @@
# Previously, we used to set CMAKE_DEBUG_POSTFIX globally. That variable should
# not be cached, however, because doing so would affect all projects processed
# after libpng, in unexpected and undesirable ways.
-set(PNG_DEBUG_POSTFIX "d"
- CACHE STRING "Postfix to append to library file names under the Debug configuration")
+if(NOT PNG_NO_DEBUG_POSTFIX)
+ set(PNG_DEBUG_POSTFIX "d"
+ CACHE STRING "Postfix to append to library file names under the Debug configuration")
+endif(NOT PNG_NO_DEBUG_POSTFIX)

# Allow the users to import their own extra configuration settings.
set(DFA_XTRA ""
@@ -488,10 +490,9 @@

if(PNG_PREFIX)
set(PNGLIBCONF_H_EXTRA_DEPENDS
- "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
- "${CMAKE_CURRENT_SOURCE_DIR}/scripts/macro.lst")
+ png_scripts_prefix_out)
set(PNGPREFIX_H_EXTRA_DEPENDS
- "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out")
+ png_scripts_intprefix_out)
endif()

generate_out(INPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c"
@@ -675,15 +676,15 @@
# We are on a Unix or Unix-like toolchain like the GNU toolchain on Windows.
# Library file names are expected to have an implicit prefix such as "lib".
# Let CMake prepend and append its usual prefixes and suffixes by default.
- set(PNG_SHARED_OUTPUT_NAME "png${PNGLIB_ABI_VERSION}")
- set(PNG_STATIC_OUTPUT_NAME "png${PNGLIB_ABI_VERSION}")
+ set(PNG_SHARED_OUTPUT_NAME "png_brl${PNGLIB_ABI_VERSION}")
+ set(PNG_STATIC_OUTPUT_NAME "png_brl${PNGLIB_ABI_VERSION}")
else()
# We are, most likely, on a Windows toolchain like MSVC, Clang on Windows,
# Borland/Embarcadero, etc. We need to specify the "libpng" name explicitly.
# We also need to use a custom suffix, in order to distinguish between the
# shared import library name and the static library name.
- set(PNG_SHARED_OUTPUT_NAME "libpng${PNGLIB_ABI_VERSION}")
- set(PNG_STATIC_OUTPUT_NAME "libpng${PNGLIB_ABI_VERSION}_static")
+ set(PNG_SHARED_OUTPUT_NAME "libpng_brl${PNGLIB_ABI_VERSION}")
+ set(PNG_STATIC_OUTPUT_NAME "libpng_brl${PNGLIB_ABI_VERSION}_static")
endif()

if(PNG_SHARED)
@@ -1072,16 +1073,16 @@
if(PNG_SHARED)
# Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin
if(NOT WIN32 OR CYGWIN OR MINGW)
- create_symlink(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png_shared)
- install(FILES $<TARGET_LINKER_FILE_DIR:png_shared>/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
+ create_symlink(libpng_brl${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png_shared)
+ install(FILES $<TARGET_LINKER_FILE_DIR:png_shared>/libpng_brl${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
endif()

if(PNG_STATIC)
if(NOT WIN32 OR CYGWIN OR MINGW)
- create_symlink(libpng${CMAKE_STATIC_LIBRARY_SUFFIX} TARGET png_static)
- install(FILES $<TARGET_LINKER_FILE_DIR:png_static>/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
+ create_symlink(libpng_brl${CMAKE_STATIC_LIBRARY_SUFFIX} TARGET png_static)
+ install(FILES $<TARGET_LINKER_FILE_DIR:png_static>/libpng_brl${CMAKE_STATIC_LIBRARY_SUFFIX}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
endif()
12 changes: 12 additions & 0 deletions png/png_zlib.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff -Naur libpng/scripts/pnglibconf.dfa PNG_BLD/scripts/pnglibconf.dfa
--- libpng/scripts/pnglibconf.dfa 2024-10-11 10:48:58.913083752 -0400
+++ PNG_BLD/scripts/pnglibconf.dfa 2024-10-11 10:48:27.026205664 -0400
@@ -343,7 +343,7 @@
# The TEXT values are the defaults when writing compressed text (all forms)

# Include the zlib header so that the defaults below are known
-@# include <zlib.h>
+@# include "zlib.h"

# The '@' here means to substitute the value when pnglibconf.h is built
setting Z_DEFAULT_COMPRESSION default @Z_DEFAULT_COMPRESSION

0 comments on commit d350f63

Please sign in to comment.