Skip to content

Conversation

olliwang
Copy link

This pull request adds support for libpng v1.6.50.

It is an update based on the existing hunter-1.6.36 branch. The underlying libpng source code is from the official v1.6.50 release.

Changes are confined to the Hunter-specific CMake configuration files (CMakeLists.txt and cmake/Config.cmake.in).

Tested and confirmed working on macOS.

@NeroBurner
Copy link

I've pushed v1.6.50 tag and created a hunter-1.6.50 branch at the state of the upstream tag.

Please update your PR such that it points to patch into the new hunter-1.6.50 branch.

This makes a review easier (or possible at all ;) )

I've also created https://github.com/cpp-pm/libpng/tree/hunter-1.6.50-neroburner with a few fixes we should integrate/discuss

@NeroBurner NeroBurner changed the base branch from hunter-1.6.36 to hunter-1.6.50 September 18, 2025 12:02
@NeroBurner
Copy link

ah I can change the base myself. Nice! 😁

Comment on lines +46 to +52
if(${CMAKE_MAJOR_VERSION} GREATER 3 OR
(${CMAKE_MAJOR_VERSION} EQUAL 3 AND ${CMAKE_MINOR_VERSION} GREATER_EQUAL 12))
# For CMake >= 3.12, find_package(<PackageName>) searches prefixes given by
# <PackageName>_ROOT CMake variable and <PackageName>_ROOT
# environment variable.
cmake_policy(SET CMP0074 NEW)
endif()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.6.50 has cmake_minimum_required(VERSION 3.14...4.0). So no need to guard here anymore

Comment on lines +53 to +54
hunter_add_package(ZLIB)
find_package(ZLIB CONFIG REQUIRED)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move that down to the original find_package(ZLIB) call?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. tested and works fine.

option(PNG_STATIC "Build libpng as a static library" ON)
if(APPLE)
option(PNG_FRAMEWORK "Build libpng as a framework bundle" ON)
option(PNG_FRAMEWORK "Build libpng as a framework bundle" OFF)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please explain the reasoning behind changing this flag

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just followed the original Hunterfied CMakeLists.txt file.

option(PNG_FRAMEWORK "Build OS X framework" OFF)

if(UNIX AND NOT (APPLE OR BEOS OR HAIKU OR EMSCRIPTEN))
check_library_exists(m pow "" PNG_HAVE_LIBM_POW)
if(LIB_M_REQUIRED)
set(M_LIBRARY m)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why have M_LIBRARY instead of using the already used PNG_LINK_LIBRARIES of this project?

target_link_libraries(png_shared
PUBLIC ${PNG_LINK_LIBRARIES})
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this isn't needed, part of the public includes of the png library

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, just tested and it's safe to remove.

INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>")
target_link_libraries(png_framework
PUBLIC ${PNG_LINK_LIBRARIES})
PRIVATE ZLIB::zlib ${M_LIBRARY})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change from PUBLIC to PRIVATE

Can't we just leave the original line with PNG_LINK_LIBRARIES?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely. Fixed in #2

endif()
target_link_libraries(${TARGET_NAME} PRIVATE ZLIB::zlib ${M_LIBRARY})

if(PNG_TESTS AND PNG_SHARED)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could replace the PNG_SHARED with BUILD_SHARED_LIBS

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rolled back most of the constants to the original code base in #2

endif()

if(PNG_SHARED AND PNG_TOOLS)
if(BUILD_SHARED_LIBS)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PNG_TOOLS got removed, please readd

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Readded in #2

@@ -0,0 +1,16 @@
include(CMakeFindDependencyMacro)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can use the PNGConfig.cmake file already available

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #2

)

# Create a CMake Config File that can be used via find_package(PNG CONFIG)
if(NOT SKIP_INSTALL_CONFIG_FILE AND NOT SKIP_INSTALL_ALL)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we keep most of the original code and change just the bits that need to be changed? Smaller patch size we need to reapply each update

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely. Added back original code in #2

@olliwang
Copy link
Author

@NeroBurner I tested your modification on the hunter-1.6.50-neroburner branch and can confirm it builds my iOS and Android projects successfully. My initial intention in adding this version was simply to address build failures with the old version on the new iOS 26 / macOS 26 SDK. Thanks for improving the changes—it works great now!

@NeroBurner
Copy link

happy to hear it works for you.

please respond to the review items as well and improve/fix them. I'd like to improve the PR even more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants