portfile.cmake 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. set(LIBPNG_VER 1.6.37)
  2. # Download the apng patch
  3. set(LIBPNG_APNG_PATCH_PATH "")
  4. set(LIBPNG_APNG_OPTION "")
  5. if ("apng" IN_LIST FEATURES)
  6. if(VCPKG_HOST_IS_WINDOWS)
  7. # Get (g)awk and gzip installed
  8. vcpkg_acquire_msys(MSYS_ROOT PACKAGES gawk gzip)
  9. set(AWK_EXE_PATH "${MSYS_ROOT}/usr/bin")
  10. vcpkg_add_to_path("${AWK_EXE_PATH}")
  11. endif()
  12. set(LIBPNG_APNG_PATCH_NAME "libpng-${LIBPNG_VER}-apng.patch")
  13. vcpkg_download_distfile(LIBPNG_APNG_PATCH_ARCHIVE
  14. URLS "https://downloads.sourceforge.net/project/libpng-apng/libpng16/${LIBPNG_VER}/${LIBPNG_APNG_PATCH_NAME}.gz"
  15. FILENAME "${LIBPNG_APNG_PATCH_NAME}.gz"
  16. SHA512 226adcb3a8c60f2267fe2976ab531329ae43c2603dab4d0cf8f16217d64069936b879f3d6516b75d259c47d6f5c5b1f24f887602206c8e46abde0fb7f5c7946b
  17. )
  18. set(LIBPNG_APNG_PATCH_PATH "${CURRENT_BUILDTREES_DIR}/src/${LIBPNG_APNG_PATCH_NAME}")
  19. if (NOT EXISTS "${LIBPNG_APNG_PATCH_PATH}")
  20. file(INSTALL "${LIBPNG_APNG_PATCH_ARCHIVE}" DESTINATION "${CURRENT_BUILDTREES_DIR}/src")
  21. vcpkg_execute_required_process(
  22. COMMAND gzip -d "${LIBPNG_APNG_PATCH_NAME}.gz"
  23. WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/src"
  24. ALLOW_IN_DOWNLOAD_MODE
  25. LOGNAME extract-patch.log
  26. )
  27. endif()
  28. set(LIBPNG_APNG_OPTION "-DPNG_PREFIX=a")
  29. endif()
  30. vcpkg_from_github(
  31. OUT_SOURCE_PATH SOURCE_PATH
  32. REPO glennrp/libpng
  33. REF v${LIBPNG_VER}
  34. SHA512 ccb3705c23b2724e86d072e2ac8cfc380f41fadfd6977a248d588a8ad57b6abe0e4155e525243011f245e98d9b7afbe2e8cc7fd4ff7d82fcefb40c0f48f88918
  35. HEAD_REF master
  36. PATCHES
  37. "${LIBPNG_APNG_PATCH_PATH}"
  38. use_abort.patch
  39. cmake.patch
  40. fix-export-targets.patch
  41. pkgconfig.patch
  42. macos-arch-fix.patch
  43. fix-msa-support-for-mips.patch
  44. )
  45. string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" PNG_SHARED)
  46. string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" PNG_STATIC)
  47. vcpkg_list(SET LIBPNG_HARDWARE_OPTIMIZATIONS_OPTION)
  48. if(VCPKG_TARGET_IS_IOS)
  49. vcpkg_list(APPEND LIBPNG_HARDWARE_OPTIMIZATIONS_OPTION "-DPNG_HARDWARE_OPTIMIZATIONS=OFF")
  50. endif()
  51. vcpkg_list(SET LD_VERSION_SCRIPT_OPTION)
  52. if(VCPKG_TARGET_IS_ANDROID)
  53. vcpkg_list(APPEND LD_VERSION_SCRIPT_OPTION "-Dld-version-script=OFF")
  54. # for armeabi-v7a, check whether NEON is available
  55. vcpkg_list(APPEND LIBPNG_HARDWARE_OPTIMIZATIONS_OPTION "-DPNG_ARM_NEON=check")
  56. else()
  57. vcpkg_list(APPEND LIBPNG_HARDWARE_OPTIMIZATIONS_OPTION "-DPNG_ARM_NEON=on")
  58. endif()
  59. vcpkg_cmake_configure(
  60. SOURCE_PATH "${SOURCE_PATH}"
  61. OPTIONS
  62. ${LIBPNG_APNG_OPTION}
  63. ${LIBPNG_HARDWARE_OPTIMIZATIONS_OPTION}
  64. ${LD_VERSION_SCRIPT_OPTION}
  65. -DPNG_STATIC=${PNG_STATIC}
  66. -DPNG_SHARED=${PNG_SHARED}
  67. -DPNG_TESTS=OFF
  68. -DSKIP_INSTALL_PROGRAMS=ON
  69. -DSKIP_INSTALL_EXECUTABLES=ON
  70. -DSKIP_INSTALL_FILES=OFF
  71. OPTIONS_DEBUG
  72. -DSKIP_INSTALL_HEADERS=ON
  73. MAYBE_UNUSED_VARIABLES
  74. PNG_ARM_NEON
  75. )
  76. vcpkg_cmake_install()
  77. vcpkg_cmake_config_fixup(CONFIG_PATH lib/libpng)
  78. file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/png")
  79. vcpkg_fixup_pkgconfig()
  80. if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
  81. if(NOT VCPKG_BUILD_TYPE)
  82. vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libpng16.pc" "-lpng16" "-llibpng16d")
  83. file(INSTALL "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libpng16.pc" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig" RENAME "libpng.pc")
  84. endif()
  85. vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/libpng16.pc" "-lpng16" "-llibpng16")
  86. elseif(NOT VCPKG_BUILD_TYPE)
  87. vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libpng16.pc" "-lpng16" "-lpng16d")
  88. file(INSTALL "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libpng16.pc" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig" RENAME "libpng.pc")
  89. endif()
  90. file(INSTALL "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/libpng16.pc" DESTINATION "${CURRENT_PACKAGES_DIR}/lib/pkgconfig" RENAME "libpng.pc")
  91. vcpkg_copy_pdbs()
  92. file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
  93. file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
  94. file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)