SDL_image: cmake: use correct libpng target + don't disable libpng versioning (348bc)

From 348bc85ed5d930b7a2789723333a7f6328defd6b Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Thu, 14 Dec 2023 16:19:59 +0100
Subject: [PATCH] cmake: use correct libpng target + don't disable libpng
 versioning

---
 CMakeLists.txt  | 7 +++++--
 external/libpng | 2 +-
 external/zlib   | 2 +-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 23a14581..eff449c1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -356,6 +356,10 @@ if(SDL2IMAGE_ZLIB)
         else()
             set(ZLIB_LIBRARY zlibstatic)
         endif()
+        # ZLIB_INCLUDE_DIRS variable is used by vendored libpng
+        set(ZLIB_INCLUDE_DIRS "${ZLIB_INCLUDE_DIR}")
+        # ZLIB_LIBRARIES variable is used by vendored libpng
+        set(ZLIB_LIBRARIES "${ZLIB_LIBRARY}")
         list(APPEND INSTALL_EXTRA_TARGETS ${ZLIB_LIBRARY})
         set_target_properties(${ZLIB_LIBRARY} PROPERTIES EXPORT_NAME external_zlib)
         add_library(SDL2_image::external_zlib ALIAS ${ZLIB_LIBRARY})
@@ -553,13 +557,12 @@ if(SDL2IMAGE_PNG)
         SDL_IMAGE_SAVE_PNG=$<BOOL:${SDL2IMAGE_PNG_SAVE}>
     )
     if(NOT SDL2IMAGE_BACKEND_STB AND NOT SDL2IMAGE_BACKEND_WIC AND NOT SDL2IMAGE_BACKEND_IMAGEIO)
-        set(HAVE_LD_VERSION_SCRIPT OFF CACHE BOOL "" FORCE)
         if(SDL2IMAGE_PNG_VENDORED)
             message(STATUS "${PROJECT_NAME}: Using vendored libpng")
             sdl_check_project_in_subfolder(external/libpng libpng SDL2IMAGE_VENDORED)
             add_subdirectory(external/libpng EXCLUDE_FROM_ALL)
             if(SDL2IMAGE_PNG_SHARED)
-                set(PNG_LIBRARY png)
+                set(PNG_LIBRARY png_shared)
             else()
                 set(PNG_LIBRARY png_static)
             endif()
diff --git a/external/libpng b/external/libpng
index bab1405b..c22c2de8 160000
--- a/external/libpng
+++ b/external/libpng
@@ -1 +1 @@
-Subproject commit bab1405bf3c2ac72b0136c54a7b7109eef1f7c10
+Subproject commit c22c2de876e0c2de7a62c6454bd6ee09ddab5571
diff --git a/external/zlib b/external/zlib
index 00c4625c..8d8abbc2 160000
--- a/external/zlib
+++ b/external/zlib
@@ -1 +1 @@
-Subproject commit 00c4625cb838018a0963ebcc7e2e9d864002a504
+Subproject commit 8d8abbc276d1151ca9df98ae6ee4638a7fe6df25