[libpng] Strong cleanup of the port (#9198)

* [libpng] strong cleanup of the port

* [libpng] do not install unhandled tools

* [libpng] restore library proper name on windows-static triplets
This commit is contained in:
Stefano Sinigardi 2019-12-24 00:26:04 +01:00 committed by dan-shaw
parent 13c4d0c18d
commit a5590520f0
8 changed files with 59 additions and 81 deletions

View File

@ -1,5 +1,5 @@
Source: libpng
Version: 1.6.37-5
Version: 1.6.37-6
Build-Depends: zlib
Homepage: https://github.com/glennrp/libpng
Description: libpng is a library implementing an interface for reading and writing PNG (Portable Network Graphics) format files.

47
ports/libpng/cmake.patch Normal file
View File

@ -0,0 +1,47 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6451fcf..6599e1d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -44,7 +44,7 @@ if(NOT PNG_BUILD_ZLIB)
endif()
if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU)
- find_library(M_LIBRARY m)
+ set(M_LIBRARY m)
else()
# libm is not needed and/or not available
set(M_LIBRARY "")
@@ -551,21 +551,14 @@ endif()
if(PNG_STATIC)
# does not work without changing name
- set(PNG_LIB_NAME_STATIC png_static)
add_library(png_static STATIC ${libpng_sources})
add_dependencies(png_static genfiles)
# MSVC doesn't use a different file extension for shared vs. static
# libs. We are able to change OUTPUT_NAME to remove the _static
# for all other platforms.
- if(NOT MSVC)
- set_target_properties(png_static PROPERTIES
- OUTPUT_NAME "${PNG_LIB_NAME}"
- CLEAN_DIRECT_OUTPUT 1)
- else()
- set_target_properties(png_static PROPERTIES
- OUTPUT_NAME "${PNG_LIB_NAME}_static"
- CLEAN_DIRECT_OUTPUT 1)
- endif()
+ set_target_properties(png_static PROPERTIES
+ OUTPUT_NAME "${PNG_LIB_NAME}"
+ CLEAN_DIRECT_OUTPUT 1)
list(APPEND PNG_LIB_TARGETS png_static)
if(MSVC)
# msvc does not append 'lib' - do it here to have consistent name
@@ -915,7 +908,7 @@ endif()
# Create an export file that CMake users can include() to import our targets.
if(NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL)
- install(EXPORT libpng DESTINATION lib/libpng FILE lib${PNG_LIB_NAME}.cmake)
+ install(EXPORT libpng DESTINATION lib/libpng FILE libpngConfig.cmake)
endif()
# what's with libpng-manual.txt and all the extra files?

View File

@ -1,12 +0,0 @@
diff -ur a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt 2019-04-14 20:10:32.000000000 +0200
+++ b/CMakeLists.txt 2019-09-06 14:14:39.425498139 +0200
@@ -44,7 +44,7 @@
endif()
if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU)
- find_library(M_LIBRARY m)
+ set(M_LIBRARY m)
else()
# libm is not needed and/or not available
set(M_LIBRARY "")

View File

@ -1,6 +0,0 @@
# The upstream CMakeLists.txt exports libpng's targets to a file named `libpng16.cmake`.
# However, `find_package(libpng CONFIG)` expects a file named `libpngConfig.cmake` to exist instead.
#
# By including `libpng.cmake` from this file, `find_package(libpng CONFIG)` will work.
get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
include("${_DIR}/libpng16.cmake")

View File

@ -13,17 +13,17 @@ if ("apng" IN_LIST FEATURES)
FILENAME "${LIBPNG_APG_PATCH_NAME}.gz"
SHA512 226adcb3a8c60f2267fe2976ab531329ae43c2603dab4d0cf8f16217d64069936b879f3d6516b75d259c47d6f5c5b1f24f887602206c8e46abde0fb7f5c7946b
)
vcpkg_find_acquire_program(7Z)
vcpkg_execute_required_process(
COMMAND ${7Z} x ${LIBPNG_APNG_PATCH_ARCHIVE} -aoa
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/src
LOGNAME extract-patch.log
)
endif()
set(APNG_EXTRA_PATCH ${LIBPNG_APG_PATCH_PATH})
set(APNG_EXTRA_PATCH ${LIBPNG_APG_PATCH_PATH})
set(LIBPNG_APNG_OPTION "-DPNG_PREFIX=a")
endif()
@ -34,8 +34,8 @@ vcpkg_from_github(
SHA512 ccb3705c23b2724e86d072e2ac8cfc380f41fadfd6977a248d588a8ad57b6abe0e4155e525243011f245e98d9b7afbe2e8cc7fd4ff7d82fcefb40c0f48f88918
HEAD_REF master
PATCHES
use-abort-on-all-platforms.patch
fix-libm-unix.patch
use_abort.patch
cmake.patch
${APNG_EXTRA_PATCH}
)
@ -58,37 +58,14 @@ vcpkg_configure_cmake(
-DSKIP_INSTALL_PROGRAMS=ON
-DSKIP_INSTALL_EXECUTABLES=ON
-DSKIP_INSTALL_FILES=ON
-DSKIP_INSTALL_SYMLINK=ON
OPTIONS_DEBUG
-DSKIP_INSTALL_HEADERS=ON
OPTIONS_DEBUG
-DSKIP_INSTALL_HEADERS=ON
)
vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/libpng)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
if(EXISTS ${CURRENT_PACKAGES_DIR}/lib/libpng16_static.lib)
file(RENAME ${CURRENT_PACKAGES_DIR}/lib/libpng16_static.lib ${CURRENT_PACKAGES_DIR}/lib/libpng16.lib)
endif()
if(EXISTS ${CURRENT_PACKAGES_DIR}/debug/lib/libpng16_staticd.lib)
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/libpng16_staticd.lib ${CURRENT_PACKAGES_DIR}/debug/lib/libpng16d.lib)
endif()
foreach(FILE ${CURRENT_PACKAGES_DIR}/share/libpng/libpng16-release.cmake ${CURRENT_PACKAGES_DIR}/share/libpng/libpng16-debug.cmake)
file(READ ${FILE} _contents)
string(REGEX REPLACE "libpng16_static.lib" "libpng16.lib" _contents "${_contents}")
string(REGEX REPLACE "libpng16_staticd.lib" "libpng16d.lib" _contents "${_contents}")
file(WRITE ${FILE} "${_contents}")
endforeach()
endif()
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share/)
file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/libpngConfig.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT})
if(NOT VCPKG_TARGET_IS_WINDOWS)
file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/png)
endif()
vcpkg_copy_pdbs()
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)

View File

@ -1,22 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 48c6fa2..589e5f9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -853,7 +853,7 @@ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR})
- if(PNG_SHARED)
+ if(PNG_SHARED AND NOT SKIP_INSTALL_SYMLINK)
# Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin
if(CYGWIN OR MINGW)
create_symlink(libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} TARGET png)
@@ -868,7 +868,7 @@ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
endif()
endif()
- if(PNG_STATIC)
+ if(PNG_STATIC AND NOT SKIP_INSTALL_SYMLINK)
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}

View File

@ -1,8 +1,8 @@
diff --git a/pngpriv.h b/pngpriv.h
index fe3355d..5a049b5 100644
index 583c26f..135651c 100644
--- a/pngpriv.h
+++ b/pngpriv.h
@@ -457,11 +457,7 @@
@@ -556,11 +556,7 @@
/* Memory model/platform independent fns */
#ifndef PNG_ABORT

View File

@ -1,6 +0,0 @@
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../lib/libpng16.a")
set(PNG_LIBRARY_RELEASE "${CMAKE_CURRENT_LIST_DIR}/../../lib/libpng16.a" CACHE FILEPATH "")
elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../lib/libpng16${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(PNG_LIBRARY_RELEASE "${CMAKE_CURRENT_LIST_DIR}/../../lib/libpng16${CMAKE_SHARED_LIBRARY_SUFFIX}" CACHE FILEPATH "")
endif()
_find_package(${ARGS})