VirtualBox

Ignore:
Timestamp:
Jan 16, 2025 1:09:46 PM (3 weeks ago)
Author:
vboxsync
Message:

libpng-1.6.45: Applied and adjusted our libpng changes to 1.6.45. bugref:8515

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/libpng-1.6.45/CMakeLists.txt

    r105469 r107813  
    1 
    21# CMakeLists.txt - CMake lists for libpng
    32#
    4 # Copyright (c) 2018-2024 Cosmin Truta.
    5 # Copyright (c) 2007-2018 Glenn Randers-Pehrson.
    6 # Originally written by Christian Ehrlicher, 2007.
     3# Copyright (c) 2018-2025 Cosmin Truta
     4# Copyright (c) 2007-2018 Glenn Randers-Pehrson
     5# Originally written by Christian Ehrlicher, 2007
    76#
    87# Use, modification and distribution are subject to
     
    1615# SPDX-License-Identifier: libpng-2.0
    1716
    18 cmake_minimum_required(VERSION 3.6)
     17cmake_minimum_required(VERSION 3.14)
    1918
    2019set(PNGLIB_MAJOR 1)
    2120set(PNGLIB_MINOR 6)
    22 set(PNGLIB_REVISION 43)
     21set(PNGLIB_REVISION 45)
    2322set(PNGLIB_SUBREVISION 0)
    2423#set(PNGLIB_SUBREVISION "git")
     
    3029        VERSION ${PNGLIB_VERSION}
    3130        LANGUAGES C ASM)
    32 
    33 if(POLICY CMP0074)
    34   # Allow find_package() to use the ZLIB_ROOT variable, if available.
    35   cmake_policy(SET CMP0074 NEW)
    36 endif()
    3731
    3832include(CheckCSourceCompiles)
     
    7064# Although these tools are targetted at development environments only,
    7165# the users are allowed to override the option to build by default.
    72 if (ANDROID OR IOS)
     66if(ANDROID OR IOS)
    7367  option(PNG_TOOLS "Build the libpng tools" OFF)
    7468else()
     
    9185option(PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations" ON)
    9286
     87# Initialize and show the target architecture variable PNG_TARGET_ARCHITECTURE.
     88#
     89# NOTE:
     90# On macOS, CMake sets CMAKE_SYSTEM_PROCESSOR to either "x86_64" or "arm64",
     91# based upon the OS architecture, not the target architecture. As such, we need
     92# to check CMAKE_OSX_ARCHITECTURES to identify which hardware-specific flags to
     93# enable. Note that this will fail if you attempt to build a universal binary
     94# in a single CMake invocation.
     95if(APPLE AND CMAKE_OSX_ARCHITECTURES)
     96  string(TOLOWER "${CMAKE_OSX_ARCHITECTURES}" PNG_TARGET_ARCHITECTURE)
     97else()
     98  string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" PNG_TARGET_ARCHITECTURE)
     99endif()
     100message(STATUS "Building for target architecture: ${PNG_TARGET_ARCHITECTURE}")
     101
    93102# Allow the users to specify a custom location of zlib.
    94 # This option is deprecated, and no longer needed with CMake 3.12 and newer.
    95 # Under the CMake policy CMP0074, if zlib is being built alongside libpng as a
    96 # subproject, its location can be passed on to CMake via the ZLIB_ROOT variable.
    97 option(PNG_BUILD_ZLIB "Custom zlib location, else find_package is used" OFF)
    98 if(NOT PNG_BUILD_ZLIB)
    99   find_package(ZLIB REQUIRED)
    100 elseif(POLICY CMP0074)
     103# With CMake 3.12 and newer, this option is no longer necessary.
     104option(PNG_BUILD_ZLIB "[Deprecated; please use ZLIB_ROOT]" OFF)
     105if(PNG_BUILD_ZLIB)
    101106  if("x${ZLIB_ROOT}" STREQUAL "x")
    102     message(DEPRECATION
    103             "The option PNG_BUILD_ZLIB has been deprecated; please use ZLIB_ROOT instead")
     107    message(SEND_ERROR
     108            "The option PNG_BUILD_ZLIB=${PNG_BUILD_ZLIB} is no longer supported; "
     109            "please use ZLIB_ROOT instead")
    104110  else()
    105111    message(SEND_ERROR
    106             "The option PNG_BUILD_ZLIB=${PNG_BUILD_ZLIB} and "
    107             "the variable ZLIB_ROOT=\"${ZLIB_ROOT}\" are mutually exclusive")
    108   endif()
    109 endif()
    110 
    111 if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU AND NOT EMSCRIPTEN)
     112            "The option PNG_BUILD_ZLIB=${PNG_BUILD_ZLIB} is no longer supported; "
     113            "using ZLIB_ROOT=\"${ZLIB_ROOT}\"")
     114  endif()
     115endif()
     116
     117find_package(ZLIB REQUIRED)
     118
     119if(UNIX
     120   AND NOT (APPLE OR BEOS OR HAIKU)
     121   AND NOT EMSCRIPTEN)
    112122  find_library(M_LIBRARY m)
    113123  if(M_LIBRARY)
     
    120130endif()
    121131
    122 # CMake currently sets CMAKE_SYSTEM_PROCESSOR to one of x86_64 or arm64 on macOS,
    123 # based upon the OS architecture, not the target architecture. As such, we need
    124 # to check CMAKE_OSX_ARCHITECTURES to identify which hardware-specific flags to
    125 # enable. Note that this will fail if you attempt to build a universal binary in
    126 # a single CMake invocation.
    127 if (APPLE AND CMAKE_OSX_ARCHITECTURES)
    128   set(TARGET_ARCH ${CMAKE_OSX_ARCHITECTURES})
    129 else()
    130   set(TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR})
    131 endif()
    132 
    133132if(PNG_HARDWARE_OPTIMIZATIONS)
    134133
    135 # Set definitions and sources for ARM.
    136 if(TARGET_ARCH MATCHES "^(ARM|arm|aarch)")
    137   if(TARGET_ARCH MATCHES "^(ARM64|arm64|aarch64)")
    138     set(PNG_ARM_NEON_POSSIBLE_VALUES on off)
    139     set(PNG_ARM_NEON "on"
    140         CACHE STRING "Enable ARM NEON optimizations: on|off; on is default")
    141   else()
    142     set(PNG_ARM_NEON_POSSIBLE_VALUES check on off)
    143     set(PNG_ARM_NEON "off"
    144         CACHE STRING "Enable ARM NEON optimizations: check|on|off; off is default")
    145   endif()
    146   set_property(CACHE PNG_ARM_NEON
    147                PROPERTY STRINGS ${PNG_ARM_NEON_POSSIBLE_VALUES})
    148   list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index)
    149   if(index EQUAL -1)
    150     message(FATAL_ERROR "PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]")
    151   elseif(NOT PNG_ARM_NEON STREQUAL "off")
    152     set(libpng_arm_sources
    153         arm/arm_init.c
    154         arm/filter_neon_intrinsics.c
    155         arm/palette_neon_intrinsics.c)
    156     if(NOT MSVC)
    157       list(APPEND libpng_arm_sources arm/filter_neon.S)
    158     endif()
    159     if(PNG_ARM_NEON STREQUAL "on")
    160       add_definitions(-DPNG_ARM_NEON_OPT=2)
    161     elseif(PNG_ARM_NEON STREQUAL "check")
    162       add_definitions(-DPNG_ARM_NEON_CHECK_SUPPORTED)
    163     endif()
    164   else()
     134  # Set definitions and sources for ARM.
     135  if(PNG_TARGET_ARCHITECTURE MATCHES "^(arm|aarch)")
     136    if(PNG_TARGET_ARCHITECTURE MATCHES "^(arm64|aarch64)")
     137      set(PNG_ARM_NEON_POSSIBLE_VALUES on off)
     138      set(PNG_ARM_NEON "on"
     139          CACHE STRING "Enable ARM NEON optimizations: on|off; on is default")
     140    else()
     141      set(PNG_ARM_NEON_POSSIBLE_VALUES check on off)
     142      set(PNG_ARM_NEON "off"
     143          CACHE STRING "Enable ARM NEON optimizations: check|on|off; off is default")
     144    endif()
     145    set_property(CACHE PNG_ARM_NEON
     146                PROPERTY STRINGS ${PNG_ARM_NEON_POSSIBLE_VALUES})
     147    list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index)
     148    if(index EQUAL -1)
     149      message(FATAL_ERROR "PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]")
     150    elseif(NOT PNG_ARM_NEON STREQUAL "off")
     151      set(libpng_arm_sources
     152          arm/arm_init.c
     153          arm/filter_neon_intrinsics.c
     154          arm/palette_neon_intrinsics.c)
     155      if(PNG_ARM_NEON STREQUAL "on")
     156        add_definitions(-DPNG_ARM_NEON_OPT=2)
     157      elseif(PNG_ARM_NEON STREQUAL "check")
     158        add_definitions(-DPNG_ARM_NEON_CHECK_SUPPORTED)
     159      endif()
     160    else()
     161      add_definitions(-DPNG_ARM_NEON_OPT=0)
     162    endif()
     163  endif()
     164
     165  # Set definitions and sources for PowerPC.
     166  if(PNG_TARGET_ARCHITECTURE MATCHES "^(powerpc|ppc64)")
     167    set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off)
     168    set(PNG_POWERPC_VSX "on"
     169        CACHE STRING "Enable POWERPC VSX optimizations: on|off; on is default")
     170    set_property(CACHE PNG_POWERPC_VSX
     171                PROPERTY STRINGS ${PNG_POWERPC_VSX_POSSIBLE_VALUES})
     172    list(FIND PNG_POWERPC_VSX_POSSIBLE_VALUES ${PNG_POWERPC_VSX} index)
     173    if(index EQUAL -1)
     174      message(FATAL_ERROR "PNG_POWERPC_VSX must be one of [${PNG_POWERPC_VSX_POSSIBLE_VALUES}]")
     175    elseif(NOT PNG_POWERPC_VSX STREQUAL "off")
     176      set(libpng_powerpc_sources
     177          powerpc/powerpc_init.c
     178          powerpc/filter_vsx_intrinsics.c)
     179      if(PNG_POWERPC_VSX STREQUAL "on")
     180        add_definitions(-DPNG_POWERPC_VSX_OPT=2)
     181      endif()
     182    else()
     183      add_definitions(-DPNG_POWERPC_VSX_OPT=0)
     184    endif()
     185  endif()
     186
     187  # Set definitions and sources for Intel.
     188  if(PNG_TARGET_ARCHITECTURE MATCHES "^(i[3-6]86|x86|amd64)")
     189    set(PNG_INTEL_SSE_POSSIBLE_VALUES on off)
     190    set(PNG_INTEL_SSE "on"
     191        CACHE STRING "Enable INTEL_SSE optimizations: on|off; on is default")
     192    set_property(CACHE PNG_INTEL_SSE
     193                PROPERTY STRINGS ${PNG_INTEL_SSE_POSSIBLE_VALUES})
     194    list(FIND PNG_INTEL_SSE_POSSIBLE_VALUES ${PNG_INTEL_SSE} index)
     195    if(index EQUAL -1)
     196      message(FATAL_ERROR "PNG_INTEL_SSE must be one of [${PNG_INTEL_SSE_POSSIBLE_VALUES}]")
     197    elseif(NOT PNG_INTEL_SSE STREQUAL "off")
     198      set(libpng_intel_sources
     199          intel/intel_init.c
     200          intel/filter_sse2_intrinsics.c)
     201      if(PNG_INTEL_SSE STREQUAL "on")
     202        add_definitions(-DPNG_INTEL_SSE_OPT=1)
     203      endif()
     204    else()
     205      add_definitions(-DPNG_INTEL_SSE_OPT=0)
     206    endif()
     207  endif()
     208
     209  # Set definitions and sources for MIPS.
     210  if(PNG_TARGET_ARCHITECTURE MATCHES "^(mipsel|mips64el)")
     211    set(PNG_MIPS_MSA_POSSIBLE_VALUES on off)
     212    set(PNG_MIPS_MSA "on"
     213        CACHE STRING "Enable MIPS_MSA optimizations: on|off; on is default")
     214    set_property(CACHE PNG_MIPS_MSA
     215                PROPERTY STRINGS ${PNG_MIPS_MSA_POSSIBLE_VALUES})
     216    list(FIND PNG_MIPS_MSA_POSSIBLE_VALUES ${PNG_MIPS_MSA} index_msa)
     217    if(index_msa EQUAL -1)
     218      message(FATAL_ERROR "PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]")
     219    endif()
     220
     221    set(PNG_MIPS_MMI_POSSIBLE_VALUES on off)
     222    set(PNG_MIPS_MMI "on"
     223        CACHE STRING "Enable MIPS_MMI optimizations: on|off; on is default")
     224    set_property(CACHE PNG_MIPS_MMI
     225                PROPERTY STRINGS ${PNG_MIPS_MMI_POSSIBLE_VALUES})
     226    list(FIND PNG_MIPS_MMI_POSSIBLE_VALUES ${PNG_MIPS_MMI} index_mmi)
     227    if(index_mmi EQUAL -1)
     228      message(FATAL_ERROR "PNG_MIPS_MMI must be one of [${PNG_MIPS_MMI_POSSIBLE_VALUES}]")
     229    endif()
     230
     231    if(PNG_MIPS_MSA STREQUAL "on" AND PNG_MIPS_MMI STREQUAL "on")
     232      set(libpng_mips_sources
     233          mips/mips_init.c
     234          mips/filter_msa_intrinsics.c
     235          mips/filter_mmi_inline_assembly.c)
     236      add_definitions(-DPNG_MIPS_MSA_OPT=2)
     237      add_definitions(-DPNG_MIPS_MMI_OPT=1)
     238    elseif(PNG_MIPS_MSA STREQUAL "on")
     239      set(libpng_mips_sources
     240          mips/mips_init.c
     241          mips/filter_msa_intrinsics.c)
     242      add_definitions(-DPNG_MIPS_MSA_OPT=2)
     243      add_definitions(-DPNG_MIPS_MMI_OPT=0)
     244    elseif(PNG_MIPS_MMI STREQUAL "on")
     245      set(libpng_mips_sources
     246          mips/mips_init.c
     247          mips/filter_mmi_inline_assembly.c)
     248      add_definitions(-DPNG_MIPS_MSA_OPT=0)
     249      add_definitions(-DPNG_MIPS_MMI_OPT=1)
     250    else()
     251      add_definitions(-DPNG_MIPS_MSA_OPT=0)
     252      add_definitions(-DPNG_MIPS_MMI_OPT=0)
     253    endif()
     254  endif()
     255
     256  # Set definitions and sources for LoongArch.
     257  if(PNG_TARGET_ARCHITECTURE MATCHES "^(loongarch)")
     258    include(CheckCCompilerFlag)
     259    set(PNG_LOONGARCH_LSX_POSSIBLE_VALUES on off)
     260    set(PNG_LOONGARCH_LSX "on"
     261        CACHE STRING "Enable LOONGARCH_LSX optimizations: on|off; on is default")
     262    set_property(CACHE PNG_LOONGARCH_LSX
     263                PROPERTY STRINGS ${PNG_LOONGARCH_LSX_POSSIBLE_VALUES})
     264    list(FIND PNG_LOONGARCH_LSX_POSSIBLE_VALUES ${PNG_LOONGARCH_LSX} index)
     265    if(index EQUAL -1)
     266      message(FATAL_ERROR "PNG_LOONGARCH_LSX must be one of [${PNG_LOONGARCH_LSX_POSSIBLE_VALUES}]")
     267    elseif(NOT PNG_LOONGARCH_LSX STREQUAL "off")
     268      CHECK_C_COMPILER_FLAG("-mlsx" COMPILER_SUPPORTS_LSX)
     269      if(COMPILER_SUPPORTS_LSX)
     270        set(libpng_loongarch_sources
     271            loongarch/loongarch_lsx_init.c
     272            loongarch/filter_lsx_intrinsics.c)
     273        set_source_files_properties(${libpng_loongarch_sources}
     274                                    PROPERTIES
     275                                    COMPILE_FLAGS "-mlsx")
     276        add_definitions(-DPNG_LOONGARCH_LSX_OPT=1)
     277      else()
     278        message(FATAL_ERROR "Compiler does not support -mlsx option")
     279      endif()
     280    else()
     281      add_definitions(-DPNG_LOONGARCH_LSX_OPT=0)
     282    endif()
     283  endif()
     284
     285else(PNG_HARDWARE_OPTIMIZATIONS)
     286
     287  # Set definitions and sources for ARM.
     288  if(PNG_TARGET_ARCHITECTURE MATCHES "^(arm|aarch)")
    165289    add_definitions(-DPNG_ARM_NEON_OPT=0)
    166290  endif()
    167 endif()
    168 
    169 # Set definitions and sources for PowerPC.
    170 if(TARGET_ARCH MATCHES "^(powerpc|ppc64)")
    171   set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off)
    172   set(PNG_POWERPC_VSX "on"
    173       CACHE STRING "Enable POWERPC VSX optimizations: on|off; on is default")
    174   set_property(CACHE PNG_POWERPC_VSX
    175                PROPERTY STRINGS ${PNG_POWERPC_VSX_POSSIBLE_VALUES})
    176   list(FIND PNG_POWERPC_VSX_POSSIBLE_VALUES ${PNG_POWERPC_VSX} index)
    177   if(index EQUAL -1)
    178     message(FATAL_ERROR "PNG_POWERPC_VSX must be one of [${PNG_POWERPC_VSX_POSSIBLE_VALUES}]")
    179   elseif(NOT PNG_POWERPC_VSX STREQUAL "off")
    180     set(libpng_powerpc_sources
    181         powerpc/powerpc_init.c
    182         powerpc/filter_vsx_intrinsics.c)
    183     if(PNG_POWERPC_VSX STREQUAL "on")
    184       add_definitions(-DPNG_POWERPC_VSX_OPT=2)
    185     endif()
    186   else()
     291
     292  # Set definitions and sources for PowerPC.
     293  if(PNG_TARGET_ARCHITECTURE MATCHES "^(powerpc|ppc64)")
    187294    add_definitions(-DPNG_POWERPC_VSX_OPT=0)
    188295  endif()
    189 endif()
    190 
    191 # Set definitions and sources for Intel.
    192 if(TARGET_ARCH MATCHES "^(i[3-6]86|x86|AMD64)")
    193   set(PNG_INTEL_SSE_POSSIBLE_VALUES on off)
    194   set(PNG_INTEL_SSE "on"
    195       CACHE STRING "Enable INTEL_SSE optimizations: on|off; on is default")
    196   set_property(CACHE PNG_INTEL_SSE
    197                PROPERTY STRINGS ${PNG_INTEL_SSE_POSSIBLE_VALUES})
    198   list(FIND PNG_INTEL_SSE_POSSIBLE_VALUES ${PNG_INTEL_SSE} index)
    199   if(index EQUAL -1)
    200     message(FATAL_ERROR "PNG_INTEL_SSE must be one of [${PNG_INTEL_SSE_POSSIBLE_VALUES}]")
    201   elseif(NOT PNG_INTEL_SSE STREQUAL "off")
    202     set(libpng_intel_sources
    203         intel/intel_init.c
    204         intel/filter_sse2_intrinsics.c)
    205     if(PNG_INTEL_SSE STREQUAL "on")
    206       add_definitions(-DPNG_INTEL_SSE_OPT=1)
    207     endif()
    208   else()
     296
     297  # Set definitions and sources for Intel.
     298  if(PNG_TARGET_ARCHITECTURE MATCHES "^(i[3-6]86|x86|amd64)")
    209299    add_definitions(-DPNG_INTEL_SSE_OPT=0)
    210300  endif()
    211 endif()
    212 
    213 # Set definitions and sources for MIPS.
    214 if(TARGET_ARCH MATCHES "^(mipsel|mips64el)")
    215   set(PNG_MIPS_MSA_POSSIBLE_VALUES on off)
    216   set(PNG_MIPS_MSA "on"
    217       CACHE STRING "Enable MIPS_MSA optimizations: on|off; on is default")
    218   set_property(CACHE PNG_MIPS_MSA
    219                PROPERTY STRINGS ${PNG_MIPS_MSA_POSSIBLE_VALUES})
    220   list(FIND PNG_MIPS_MSA_POSSIBLE_VALUES ${PNG_MIPS_MSA} index_msa)
    221   if(index_msa EQUAL -1)
    222     message(FATAL_ERROR "PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]")
    223   endif()
    224 
    225   set(PNG_MIPS_MMI_POSSIBLE_VALUES on off)
    226   set(PNG_MIPS_MMI "on"
    227       CACHE STRING "Enable MIPS_MMI optimizations: on|off; on is default")
    228   set_property(CACHE PNG_MIPS_MMI
    229                PROPERTY STRINGS ${PNG_MIPS_MMI_POSSIBLE_VALUES})
    230   list(FIND PNG_MIPS_MMI_POSSIBLE_VALUES ${PNG_MIPS_MMI} index_mmi)
    231   if(index_mmi EQUAL -1)
    232     message(FATAL_ERROR "PNG_MIPS_MMI must be one of [${PNG_MIPS_MMI_POSSIBLE_VALUES}]")
    233   endif()
    234 
    235   if(PNG_MIPS_MSA STREQUAL "on" AND PNG_MIPS_MMI STREQUAL "on")
    236     set(libpng_mips_sources
    237         mips/mips_init.c
    238         mips/filter_msa_intrinsics.c
    239         mips/filter_mmi_inline_assembly.c)
    240     add_definitions(-DPNG_MIPS_MSA_OPT=2)
    241     add_definitions(-DPNG_MIPS_MMI_OPT=1)
    242   elseif(PNG_MIPS_MSA STREQUAL "on")
    243     set(libpng_mips_sources
    244         mips/mips_init.c
    245         mips/filter_msa_intrinsics.c)
    246     add_definitions(-DPNG_MIPS_MSA_OPT=2)
    247     add_definitions(-DPNG_MIPS_MMI_OPT=0)
    248   elseif(PNG_MIPS_MMI STREQUAL "on")
    249     set(libpng_mips_sources
    250         mips/mips_init.c
    251         mips/filter_mmi_inline_assembly.c)
     301
     302  # Set definitions and sources for MIPS.
     303  if(PNG_TARGET_ARCHITECTURE MATCHES "^(mipsel|mips64el)")
    252304    add_definitions(-DPNG_MIPS_MSA_OPT=0)
    253     add_definitions(-DPNG_MIPS_MMI_OPT=1)
    254     else()
    255     add_definitions(-DPNG_MIPS_MSA_OPT=0)
    256     add_definitions(-DPNG_MIPS_MMI_OPT=0)
    257     endif()
    258 endif()
    259 
    260 # Set definitions and sources for LoongArch.
    261 if(TARGET_ARCH MATCHES "^(loongarch)")
    262   include(CheckCCompilerFlag)
    263   set(PNG_LOONGARCH_LSX_POSSIBLE_VALUES on off)
    264   set(PNG_LOONGARCH_LSX "on"
    265       CACHE STRING "Enable LOONGARCH_LSX optimizations: on|off; on is default")
    266   set_property(CACHE PNG_LOONGARCH_LSX
    267                PROPERTY STRINGS ${PNG_LOONGARCH_LSX_POSSIBLE_VALUES})
    268   list(FIND PNG_LOONGARCH_LSX_POSSIBLE_VALUES ${PNG_LOONGARCH_LSX} index)
    269   if(index EQUAL -1)
    270     message(FATAL_ERROR "PNG_LOONGARCH_LSX must be one of [${PNG_LOONGARCH_LSX_POSSIBLE_VALUES}]")
    271   elseif(NOT PNG_LOONGARCH_LSX STREQUAL "off")
    272     CHECK_C_COMPILER_FLAG("-mlsx" COMPILER_SUPPORTS_LSX)
    273     if(COMPILER_SUPPORTS_LSX)
    274       set(libpng_loongarch_sources
    275           loongarch/loongarch_lsx_init.c
    276           loongarch/filter_lsx_intrinsics.c)
    277       set_source_files_properties(${libpng_loongarch_sources}
    278                                   PROPERTIES
    279                                   COMPILE_FLAGS "-mlsx")
    280       add_definitions(-DPNG_LOONGARCH_LSX_OPT=1)
    281     else()
    282       message(FATAL_ERROR "Compiler does not support -mlsx option")
    283     endif()
    284   else()
     305  endif()
     306
     307  # Set definitions and sources for LoongArch.
     308  if(PNG_TARGET_ARCHITECTURE MATCHES "^(loongarch)")
    285309    add_definitions(-DPNG_LOONGARCH_LSX_OPT=0)
    286310  endif()
    287 endif()
    288 
    289 else(PNG_HARDWARE_OPTIMIZATIONS)
    290 
    291 # Set definitions and sources for ARM.
    292 if(TARGET_ARCH MATCHES "^(ARM|arm|aarch)")
    293   add_definitions(-DPNG_ARM_NEON_OPT=0)
    294 endif()
    295 
    296 # Set definitions and sources for PowerPC.
    297 if(TARGET_ARCH MATCHES "^(powerpc|ppc64)")
    298   add_definitions(-DPNG_POWERPC_VSX_OPT=0)
    299 endif()
    300 
    301 # Set definitions and sources for Intel.
    302 if(TARGET_ARCH MATCHES "^(i[3-6]86|x86|AMD64)")
    303   add_definitions(-DPNG_INTEL_SSE_OPT=0)
    304 endif()
    305 
    306 # Set definitions and sources for MIPS.
    307 if(TARGET_ARCH MATCHES "^(mipsel|mips64el)")
    308   add_definitions(-DPNG_MIPS_MSA_OPT=0)
    309 endif()
    310 
    311 # Set definitions and sources for LoongArch.
    312 if(TARGET_ARCH MATCHES "^(loongarch)")
    313   add_definitions(-DPNG_LOONGARCH_LSX_OPT=0)
    314 endif()
    315311
    316312endif(PNG_HARDWARE_OPTIMIZATIONS)
    317313
    318314option(ld-version-script "Enable linker version script" ON)
    319 if(ld-version-script AND NOT ANDROID AND NOT APPLE)
     315if(ld-version-script AND NOT (ANDROID OR APPLE))
    320316  # Check if LD supports linker scripts.
    321317  file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "
     
    363359endif()
    364360
    365 include_directories(${CMAKE_CURRENT_BINARY_DIR})
    366 
    367 if(NOT AWK OR ANDROID OR IOS)
     361if(NOT AWK OR (ANDROID OR IOS))
    368362  # No awk available to generate sources; use pre-built pnglibconf.h
    369363  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
     
    371365  add_custom_target(png_genfiles)
    372366else()
     367  # Include the internal module PNGGenConfig.cmake
     368  include(${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/PNGGenConfig.cmake)
     369
    373370  # Copy the awk scripts, converting their line endings to Unix (LF)
    374371  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk
     
    384381                 @ONLY
    385382                 NEWLINE_STYLE LF)
    386 
    387   # Generate .chk from .out with awk:
    388   # generate_chk(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
    389   function(generate_chk)
    390     set(options)
    391     set(oneValueArgs INPUT OUTPUT)
    392     set(multiValueArgs DEPENDS)
    393     cmake_parse_arguments(_GC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
    394     if(NOT _GC_INPUT)
    395       message(FATAL_ERROR "generate_chk: Missing INPUT argument")
    396     endif()
    397     if(NOT _GC_OUTPUT)
    398       message(FATAL_ERROR "generate_chk: Missing OUTPUT argument")
    399     endif()
    400 
    401     add_custom_command(OUTPUT "${_GC_OUTPUT}"
    402                        COMMAND "${CMAKE_COMMAND}"
    403                                "-DINPUT=${_GC_INPUT}"
    404                                "-DOUTPUT=${_GC_OUTPUT}"
    405                                -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/genchk.cmake"
    406                        DEPENDS "${_GC_INPUT}" ${_GC_DEPENDS}
    407                        WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
    408   endfunction()
    409 
    410   # Generate .out from .c with awk
    411   # generate_out(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
    412   function(generate_out)
    413     set(options)
    414     set(oneValueArgs INPUT OUTPUT)
    415     set(multiValueArgs DEPENDS)
    416     cmake_parse_arguments(_GO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
    417     if(NOT _GO_INPUT)
    418       message(FATAL_ERROR "generate_out: Missing INPUT argument")
    419     endif()
    420     if(NOT _GO_OUTPUT)
    421       message(FATAL_ERROR "generate_out: Missing OUTPUT argument")
    422     endif()
    423 
    424     add_custom_command(OUTPUT "${_GO_OUTPUT}"
    425                        COMMAND "${CMAKE_COMMAND}"
    426                                "-DINPUT=${_GO_INPUT}"
    427                                "-DOUTPUT=${_GO_OUTPUT}"
    428                                -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/genout.cmake"
    429                        DEPENDS "${_GO_INPUT}" ${_GO_DEPENDS}
    430                        WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
    431   endfunction()
    432 
    433   # Generate specific source file with awk
    434   # generate_source(OUTPUT outputfile [DEPENDS dep1 [dep2...]])
    435   function(generate_source)
    436     set(options)
    437     set(oneValueArgs OUTPUT)
    438     set(multiValueArgs DEPENDS)
    439     cmake_parse_arguments(_GSO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
    440     if(NOT _GSO_OUTPUT)
    441       message(FATAL_ERROR "generate_source: Missing OUTPUT argument")
    442     endif()
    443 
    444     add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}"
    445                        COMMAND "${CMAKE_COMMAND}"
    446                                "-DOUTPUT=${_GSO_OUTPUT}"
    447                                -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/gensrc.cmake"
    448                        DEPENDS ${_GSO_DEPENDS}
    449                        WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
    450   endfunction()
    451 
    452   # Copy file
    453   # generate_copy(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
    454   function(generate_copy)
    455     set(options)
    456     set(oneValueArgs INPUT OUTPUT)
    457     set(multiValueArgs DEPENDS)
    458     cmake_parse_arguments(_GCO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
    459     if(NOT _GCO_INPUT)
    460       message(FATAL_ERROR "generate_copy: Missing INPUT argument")
    461     endif()
    462     if(NOT _GCO_OUTPUT)
    463       message(FATAL_ERROR "generate_copy: Missing OUTPUT argument")
    464     endif()
    465 
    466     add_custom_command(OUTPUT "${_GCO_OUTPUT}"
    467                        COMMAND "${CMAKE_COMMAND}"
    468                                -E remove "${_GCO_OUTPUT}"
    469                        COMMAND "${CMAKE_COMMAND}"
    470                                -E copy "${_GCO_INPUT}" "${_GCO_OUTPUT}"
    471                        DEPENDS "${source}" ${_GCO_DEPENDS})
    472   endfunction()
    473383
    474384  # Generate scripts/pnglibconf.h
     
    593503                            "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" png_scripts_symbols_out
    594504                            "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out" png_scripts_vers_out)
    595 endif(NOT AWK OR ANDROID OR IOS)
     505endif(NOT AWK OR (ANDROID OR IOS))
    596506
    597507# List the source code files.
     
    607517    pngstruct.h
    608518)
    609 if(AWK AND NOT ANDROID AND NOT IOS)
     519if(AWK AND NOT (ANDROID OR IOS))
    610520  list(APPEND libpng_private_hdrs "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h")
    611521endif()
     
    715625  target_include_directories(png_shared
    716626                             PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
     627  target_include_directories(png_shared
     628                             PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
    717629  target_include_directories(png_shared SYSTEM
    718630                             INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>)
     
    729641  target_include_directories(png_static
    730642                             PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
     643  target_include_directories(png_static
     644                             PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
    731645  target_include_directories(png_static SYSTEM
    732646                             INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>)
     
    758672  target_include_directories(png_framework
    759673                             PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
     674  target_include_directories(png_framework
     675                             PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
    760676  target_include_directories(png_framework SYSTEM
    761677                             INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>)
     
    772688  enable_testing()
    773689
    774   function(png_add_test)
    775     set(options)
    776     set(oneValueArgs NAME COMMAND)
    777     set(multiValueArgs OPTIONS FILES)
    778     cmake_parse_arguments(_PAT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
    779     if(NOT _PAT_NAME)
    780       message(FATAL_ERROR "png_add_test: Missing NAME argument")
    781     endif()
    782     if(NOT _PAT_COMMAND)
    783       message(FATAL_ERROR "png_add_test: Missing COMMAND argument")
    784     endif()
    785 
    786     set(TEST_OPTIONS "${_PAT_OPTIONS}")
    787     set(TEST_FILES "${_PAT_FILES}")
    788 
    789     configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/test.cmake.in"
    790                    "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake"
    791                    @ONLY)
    792     add_test(NAME "${_PAT_NAME}"
    793              COMMAND "${CMAKE_COMMAND}"
    794                      "-DLIBPNG=$<TARGET_FILE:png_shared>"
    795                      "-DTEST_COMMAND=$<TARGET_FILE:${_PAT_COMMAND}>"
    796                      -P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake")
    797   endfunction()
     690  # Include the internal module PNGTest.cmake
     691  include(${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/PNGTest.cmake)
    798692
    799693  # Find test PNG files by globbing, but sort lists to ensure
     
    803697  file(GLOB TEST_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/testpngs/*.png")
    804698  list(SORT TEST_PNGS)
     699  file(GLOB TEST_PNG3_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/testpngs/png-3/*.png")
     700  list(SORT TEST_PNG3_PNGS)
    805701
    806702  set(PNGTEST_PNG "${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png")
     
    812708               COMMAND pngtest
    813709               FILES "${PNGTEST_PNG}")
     710
     711  png_add_test(NAME pngtest-png-3
     712               COMMAND pngtest
     713               FILES "${TEST_PNG3_PNGS}")
    814714
    815715  add_executable(pngvalid ${pngvalid_sources})
     
    969869endif()
    970870
    971 # Create a symlink from src to dest (if possible), or, alternatively,
    972 # copy src to dest if different.
     871# Create a symlink that points to a target file (if symlinking is possible),
     872# or make a copy of the target file (if symlinking is not possible):
     873# create_symlink(<destfile> [FILE <file> | TARGET <target>])
    973874function(create_symlink DEST_FILE)
     875  # TODO:
     876  # Replace this implementation with CMake's built-in create_symlink function,
     877  # which has been fully functional on all platforms, including Windows, since
     878  # CMake version 3.13.
    974879  cmake_parse_arguments(_SYM "" "FILE;TARGET" "" ${ARGN})
    975880  if(NOT _SYM_FILE AND NOT _SYM_TARGET)
     
    11291034endif()
    11301035
     1036# Create a CMake Config File that can be used via find_package(PNG CONFIG)
     1037if(NOT SKIP_INSTALL_CONFIG_FILE AND NOT SKIP_INSTALL_ALL)
     1038  install(TARGETS ${PNG_LIBRARY_TARGETS}
     1039          EXPORT PNGTargets
     1040          RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
     1041          LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
     1042          ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
     1043          FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR})
     1044
     1045  include(CMakePackageConfigHelpers)
     1046  write_basic_package_version_file(PNGConfigVersion.cmake
     1047                                   VERSION ${PNGLIB_VERSION}
     1048                                   COMPATIBILITY SameMinorVersion)
     1049
     1050  install(EXPORT PNGTargets
     1051          FILE PNGTargets.cmake
     1052          NAMESPACE PNG::
     1053          DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PNG)
     1054
     1055  install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/PNGConfig.cmake
     1056                ${CMAKE_CURRENT_BINARY_DIR}/PNGConfigVersion.cmake
     1057          DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PNG)
     1058endif()
     1059
    11311060# TODO: Create MSVC import lib for MinGW-compiled shared lib.
    11321061# pexports libpng.dll > libpng.def
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette