1diff --git a/CMakeLists.txt b/CMakeLists.txt 2index 8652564b6..639554ad8 100644 3--- a/CMakeLists.txt 4+++ b/CMakeLists.txt 5@@ -1,1040 +1,26 @@ 6-# CMakeLists.txt 7- 8-# Copyright (c) 2018-2022 Cosmin Truta 9-# Copyright (c) 2007,2009-2018 Glenn Randers-Pehrson 10-# Written by Christian Ehrlicher, 2007 11-# Revised by Roger Lowman, 2009-2010 12-# Revised by Clifford Yapp, 2011-2012,2017 13-# Revised by Roger Leigh, 2016 14-# Revised by Andreas Franek, 2016 15-# Revised by Sam Serrels, 2017 16-# Revised by Vadim Barkov, 2017 17-# Revised by Vicky Pfau, 2018 18-# Revised by Cameron Cawley, 2018,2021 19-# Revised by Kyle Bentley, 2018 20-# Revised by David Callu, 2020 21-# Revised by Steve Robinson, 2020 22-# Revised by Simon Hausmann, 2020 23-# Revised by Alex Gaynor, 2020 24-# Revised by Owen Rudge, 2020 25-# Revised by Gleb Mazovetskiy, 2021 26-# Revised by Christopher Sean Morrison, 2022 27- 28-# This code is released under the libpng license. 29-# For conditions of distribution and use, see the disclaimer 30-# and license in png.h 31- 32-cmake_minimum_required(VERSION 3.1) 33-cmake_policy(VERSION 3.1) 34- 35-project(libpng C ASM) 36-enable_testing() 37- 38-set(PNGLIB_MAJOR 1) 39-set(PNGLIB_MINOR 6) 40-set(PNGLIB_REVISION 38) 41-set(PNGLIB_SUBREVISION 0) 42-#set(PNGLIB_SUBREVISION "git") 43-set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}) 44-set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_REVISION}) 45-set(PNGLIB_SHARED_SOVERSION ${PNGLIB_MAJOR}${PNGLIB_MINOR}) 46-set(PNGLIB_SHARED_VERSION ${PNGLIB_SHARED_SOVERSION}.${PNGLIB_REVISION}.${PNGLIB_SUBREVISION}) 47- 48-include(GNUInstallDirs) 49- 50-# Allow users to specify location of zlib. 51-# Useful if zlib is being built alongside this as a sub-project. 52-option(PNG_BUILD_ZLIB "Custom zlib Location, else find_package is used" OFF) 53- 54-if(NOT PNG_BUILD_ZLIB) 55- find_package(ZLIB REQUIRED) 56- include_directories(${ZLIB_INCLUDE_DIRS}) 57-endif() 58- 59-if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU AND NOT EMSCRIPTEN) 60- find_library(M_LIBRARY m) 61- if(NOT M_LIBRARY) 62- set(M_LIBRARY "") 63- endif() 64-else() 65- # libm is not needed and/or not available. 66- set(M_LIBRARY "") 67-endif() 68- 69-# Public CMake configuration variables. 70-option(PNG_SHARED "Build shared lib" ON) 71-option(PNG_STATIC "Build static lib" ON) 72-option(PNG_EXECUTABLES "Build libpng executables" ON) 73-option(PNG_TESTS "Build libpng tests" ON) 74- 75-# Many more configuration options could be added here. 76-option(PNG_FRAMEWORK "Build OS X framework" OFF) 77-option(PNG_DEBUG "Build with debug output" OFF) 78-option(PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations" ON) 79- 80-set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names") 81-set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings") 82- 83-# CMake currently sets CMAKE_SYSTEM_PROCESSOR to one of x86_64 or arm64 on macOS, 84-# based upon the OS architecture, not the target architecture. As such, we need 85-# to check CMAKE_OSX_ARCHITECTURES to identify which hardware-specific flags to 86-# enable. Note that this will fail if you attempt to build a universal binary in 87-# a single CMake invocation. 88-if (APPLE AND CMAKE_OSX_ARCHITECTURES) 89- set(TARGET_ARCH ${CMAKE_OSX_ARCHITECTURES}) 90-else() 91- set(TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR}) 92-endif() 93- 94-if(PNG_HARDWARE_OPTIMIZATIONS) 95- 96-# Set definitions and sources for ARM. 97-if(TARGET_ARCH MATCHES "^arm" OR 98- TARGET_ARCH MATCHES "^aarch64") 99- if(TARGET_ARCH MATCHES "^arm64" OR 100- TARGET_ARCH MATCHES "^aarch64") 101- set(PNG_ARM_NEON_POSSIBLE_VALUES on off) 102- set(PNG_ARM_NEON "on" 103- CACHE STRING "Enable ARM NEON optimizations: on|off; on is default") 104- else() 105- set(PNG_ARM_NEON_POSSIBLE_VALUES check on off) 106- set(PNG_ARM_NEON "check" 107- CACHE STRING "Enable ARM NEON optimizations: check|on|off; check is default") 108- endif() 109- set_property(CACHE PNG_ARM_NEON 110- PROPERTY STRINGS ${PNG_ARM_NEON_POSSIBLE_VALUES}) 111- list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index) 112- if(index EQUAL -1) 113- message(FATAL_ERROR "PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]") 114- elseif(NOT ${PNG_ARM_NEON} STREQUAL "off") 115- set(libpng_arm_sources 116- arm/arm_init.c 117- arm/filter_neon.S 118- arm/filter_neon_intrinsics.c 119- arm/palette_neon_intrinsics.c) 120- if(${PNG_ARM_NEON} STREQUAL "on") 121- add_definitions(-DPNG_ARM_NEON_OPT=2) 122- elseif(${PNG_ARM_NEON} STREQUAL "check") 123- add_definitions(-DPNG_ARM_NEON_CHECK_SUPPORTED) 124- endif() 125- else() 126- add_definitions(-DPNG_ARM_NEON_OPT=0) 127- endif() 128-endif() 129- 130-# Set definitions and sources for PowerPC. 131-if(TARGET_ARCH MATCHES "^powerpc*" OR 132- TARGET_ARCH MATCHES "^ppc64*") 133- set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off) 134- set(PNG_POWERPC_VSX "on" 135- CACHE STRING "Enable POWERPC VSX optimizations: on|off; on is default") 136- set_property(CACHE PNG_POWERPC_VSX 137- PROPERTY STRINGS ${PNG_POWERPC_VSX_POSSIBLE_VALUES}) 138- list(FIND PNG_POWERPC_VSX_POSSIBLE_VALUES ${PNG_POWERPC_VSX} index) 139- if(index EQUAL -1) 140- message(FATAL_ERROR "PNG_POWERPC_VSX must be one of [${PNG_POWERPC_VSX_POSSIBLE_VALUES}]") 141- elseif(NOT ${PNG_POWERPC_VSX} STREQUAL "off") 142- set(libpng_powerpc_sources 143- powerpc/powerpc_init.c 144- powerpc/filter_vsx_intrinsics.c) 145- if(${PNG_POWERPC_VSX} STREQUAL "on") 146- add_definitions(-DPNG_POWERPC_VSX_OPT=2) 147- endif() 148- else() 149- add_definitions(-DPNG_POWERPC_VSX_OPT=0) 150- endif() 151-endif() 152- 153-# Set definitions and sources for Intel. 154-if(TARGET_ARCH MATCHES "^i?86" OR 155- TARGET_ARCH MATCHES "^x86_64*") 156- set(PNG_INTEL_SSE_POSSIBLE_VALUES on off) 157- set(PNG_INTEL_SSE "on" 158- CACHE STRING "Enable INTEL_SSE optimizations: on|off; on is default") 159- set_property(CACHE PNG_INTEL_SSE 160- PROPERTY STRINGS ${PNG_INTEL_SSE_POSSIBLE_VALUES}) 161- list(FIND PNG_INTEL_SSE_POSSIBLE_VALUES ${PNG_INTEL_SSE} index) 162- if(index EQUAL -1) 163- message(FATAL_ERROR "PNG_INTEL_SSE must be one of [${PNG_INTEL_SSE_POSSIBLE_VALUES}]") 164- elseif(NOT ${PNG_INTEL_SSE} STREQUAL "off") 165- set(libpng_intel_sources 166- intel/intel_init.c 167- intel/filter_sse2_intrinsics.c) 168- if(${PNG_INTEL_SSE} STREQUAL "on") 169- add_definitions(-DPNG_INTEL_SSE_OPT=1) 170- endif() 171- else() 172- add_definitions(-DPNG_INTEL_SSE_OPT=0) 173- endif() 174-endif() 175- 176-# Set definitions and sources for MIPS. 177-if(TARGET_ARCH MATCHES "mipsel*" OR 178- TARGET_ARCH MATCHES "mips64el*") 179- set(PNG_MIPS_MSA_POSSIBLE_VALUES on off) 180- set(PNG_MIPS_MSA "on" 181- CACHE STRING "Enable MIPS_MSA optimizations: on|off; on is default") 182- set_property(CACHE PNG_MIPS_MSA 183- PROPERTY STRINGS ${PNG_MIPS_MSA_POSSIBLE_VALUES}) 184- list(FIND PNG_MIPS_MSA_POSSIBLE_VALUES ${PNG_MIPS_MSA} index) 185- if(index EQUAL -1) 186- message(FATAL_ERROR "PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]") 187- elseif(NOT ${PNG_MIPS_MSA} STREQUAL "off") 188- set(libpng_mips_sources 189- mips/mips_init.c 190- mips/filter_msa_intrinsics.c) 191- if(${PNG_MIPS_MSA} STREQUAL "on") 192- add_definitions(-DPNG_MIPS_MSA_OPT=2) 193- endif() 194- else() 195- add_definitions(-DPNG_MIPS_MSA_OPT=0) 196- endif() 197-endif() 198- 199-else(PNG_HARDWARE_OPTIMIZATIONS) 200- 201-# Set definitions and sources for ARM. 202-if(TARGET_ARCH MATCHES "^arm" OR 203- TARGET_ARCH MATCHES "^aarch64") 204- add_definitions(-DPNG_ARM_NEON_OPT=0) 205-endif() 206- 207-# Set definitions and sources for PowerPC. 208-if(TARGET_ARCH MATCHES "^powerpc*" OR 209- TARGET_ARCH MATCHES "^ppc64*") 210- add_definitions(-DPNG_POWERPC_VSX_OPT=0) 211-endif() 212- 213-# Set definitions and sources for Intel. 214-if(TARGET_ARCH MATCHES "^i?86" OR 215- TARGET_ARCH MATCHES "^x86_64*") 216- add_definitions(-DPNG_INTEL_SSE_OPT=0) 217-endif() 218- 219-# Set definitions and sources for MIPS. 220-if(TARGET_ARCH MATCHES "mipsel*" OR 221- TARGET_ARCH MATCHES "mips64el*") 222- add_definitions(-DPNG_MIPS_MSA_OPT=0) 223-endif() 224- 225-endif(PNG_HARDWARE_OPTIMIZATIONS) 226- 227-# Set PNG_LIB_NAME. 228-set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR}) 229- 230-# Distinguish between debug and release builds. 231-set(CMAKE_DEBUG_POSTFIX "d") 232- 233-include(CheckCSourceCompiles) 234-option(ld-version-script "Enable linker version script" ON) 235-if(ld-version-script AND NOT ANDROID AND NOT APPLE) 236- # Check if LD supports linker scripts. 237- file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" " 238-VERS_1 { 239- global: sym; 240- local: *; 241-}; 242- 243-VERS_2 { 244- global: sym2; 245- main; 246-} VERS_1; 247-") 248- set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) 249- set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'") 250- check_c_source_compiles("void sym(void) {} 251-void sym2(void) {} 252-int main(void) {return 0;} 253-" HAVE_LD_VERSION_SCRIPT) 254- if(NOT HAVE_LD_VERSION_SCRIPT) 255- set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE} "-Wl,-M -Wl,${CMAKE_CURRENT_BINARY_DIR}/conftest.map") 256- check_c_source_compiles("void sym(void) {} 257-void sym2(void) {} 258-int main(void) {return 0;} 259-" HAVE_SOLARIS_LD_VERSION_SCRIPT) 260- endif() 261- set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) 262- file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map") 263-endif() 264- 265-# Find symbol prefix. Likely obsolete and unnecessary with recent 266-# toolchains (it's not done in many other projects). 267-function(symbol_prefix) 268- set(SYMBOL_PREFIX) 269- 270- execute_process(COMMAND "${CMAKE_C_COMPILER}" "-E" "-" 271- INPUT_FILE /dev/null 272- OUTPUT_VARIABLE OUT 273- RESULT_VARIABLE STATUS) 274- 275- if(CPP_FAIL) 276- message(WARNING "Failed to run the C preprocessor") 277- endif() 278- 279- string(REPLACE "\n" ";" OUT "${OUT}") 280- foreach(line ${OUT}) 281- string(REGEX MATCH "^PREFIX=" found_match "${line}") 282- if(found_match) 283- string(REGEX REPLACE "^PREFIX=(.*\)" "\\1" prefix "${line}") 284- string(REGEX MATCH "__USER_LABEL_PREFIX__" found_match "${prefix}") 285- if(found_match) 286- string(REGEX REPLACE "(.*)__USER_LABEL_PREFIX__(.*)" "\\1\\2" prefix "${prefix}") 287- endif() 288- set(SYMBOL_PREFIX "${prefix}") 289- endif() 290- endforeach() 291- 292- message(STATUS "Symbol prefix: ${SYMBOL_PREFIX}") 293- set(SYMBOL_PREFIX "${SYMBOL_PREFIX}" PARENT_SCOPE) 294-endfunction() 295- 296-if(UNIX) 297- symbol_prefix() 298-endif() 299- 300-find_program(AWK NAMES gawk awk) 301- 302-include_directories(${CMAKE_CURRENT_BINARY_DIR}) 303- 304-if(NOT AWK OR ANDROID OR IOS) 305- # No awk available to generate sources; use pre-built pnglibconf.h 306- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt 307- ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h) 308- add_custom_target(genfiles) # Dummy 309-else() 310- # Copy the awk scripts, converting their line endings to Unix (LF) 311- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk 312- ${CMAKE_CURRENT_BINARY_DIR}/scripts/checksym.awk 313- @ONLY 314- NEWLINE_STYLE LF) 315- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk 316- ${CMAKE_CURRENT_BINARY_DIR}/scripts/options.awk 317- @ONLY 318- NEWLINE_STYLE LF) 319- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/dfn.awk 320- ${CMAKE_CURRENT_BINARY_DIR}/scripts/dfn.awk 321- @ONLY 322- NEWLINE_STYLE LF) 323- 324- # Generate .chk from .out with awk: 325- # generate_chk(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]]) 326- include(CMakeParseArguments) 327- function(generate_chk) 328- set(options) 329- set(oneValueArgs INPUT OUTPUT) 330- set(multiValueArgs DEPENDS) 331- cmake_parse_arguments(_GC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 332- if(NOT _GC_INPUT) 333- message(FATAL_ERROR "generate_chk: Missing INPUT argument") 334- endif() 335- if(NOT _GC_OUTPUT) 336- message(FATAL_ERROR "generate_chk: Missing OUTPUT argument") 337- endif() 338- 339- add_custom_command(OUTPUT "${_GC_OUTPUT}" 340- COMMAND "${CMAKE_COMMAND}" 341- "-DINPUT=${_GC_INPUT}" 342- "-DOUTPUT=${_GC_OUTPUT}" 343- -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake" 344- DEPENDS "${_GC_INPUT}" ${_GC_DEPENDS} 345- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") 346- endfunction() 347- 348- # Generate .out from .c with awk 349- # generate_out(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]]) 350- function(generate_out) 351- set(options) 352- set(oneValueArgs INPUT OUTPUT) 353- set(multiValueArgs DEPENDS) 354- cmake_parse_arguments(_GO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 355- if(NOT _GO_INPUT) 356- message(FATAL_ERROR "generate_out: Missing INPUT argument") 357- endif() 358- if(NOT _GO_OUTPUT) 359- message(FATAL_ERROR "generate_out: Missing OUTPUT argument") 360- endif() 361- 362- add_custom_command(OUTPUT "${_GO_OUTPUT}" 363- COMMAND "${CMAKE_COMMAND}" 364- "-DINPUT=${_GO_INPUT}" 365- "-DOUTPUT=${_GO_OUTPUT}" 366- -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake" 367- DEPENDS "${_GO_INPUT}" ${_GO_DEPENDS} 368- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") 369- endfunction() 370- 371- # Generate specific source file with awk 372- # generate_source(OUTPUT outputfile [DEPENDS dep1 [dep2...]]) 373- function(generate_source) 374- set(options) 375- set(oneValueArgs OUTPUT) 376- set(multiValueArgs DEPENDS) 377- cmake_parse_arguments(_GSO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 378- if(NOT _GSO_OUTPUT) 379- message(FATAL_ERROR "generate_source: Missing OUTPUT argument") 380- endif() 381- 382- add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}" 383- COMMAND "${CMAKE_COMMAND}" 384- "-DOUTPUT=${_GSO_OUTPUT}" 385- -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake" 386- DEPENDS ${_GSO_DEPENDS} 387- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") 388- endfunction() 389- 390- # Copy file 391- # generate_copy(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]]) 392- function(generate_copy) 393- set(options) 394- set(oneValueArgs INPUT OUTPUT) 395- set(multiValueArgs DEPENDS) 396- cmake_parse_arguments(_GCO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 397- add_custom_command(OUTPUT "${_GCO_OUTPUT}" 398- COMMAND "${CMAKE_COMMAND}" 399- -E remove "${_GCO_OUTPUT}" 400- COMMAND "${CMAKE_COMMAND}" 401- -E copy "${_GCO_INPUT}" "${_GCO_OUTPUT}" 402- DEPENDS "${source}" ${_GCO_DEPENDS}) 403- endfunction() 404- 405- # Generate scripts/pnglibconf.h 406- generate_source(OUTPUT "scripts/pnglibconf.c" 407- DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa" 408- "${CMAKE_CURRENT_BINARY_DIR}/scripts/options.awk" 409- "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h") 410- add_custom_target(scripts_pnglibconf_c DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c") 411- 412- # Generate pnglibconf.c 413- generate_source(OUTPUT "pnglibconf.c" 414- DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa" 415- "${CMAKE_CURRENT_BINARY_DIR}/scripts/options.awk" 416- "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h") 417- add_custom_target(pnglibconf_c DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c") 418- 419- if(PNG_PREFIX) 420- set(PNGLIBCONF_H_EXTRA_DEPENDS 421- "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" 422- "${CMAKE_CURRENT_SOURCE_DIR}/scripts/macro.lst") 423- set(PNGPREFIX_H_EXTRA_DEPENDS 424- "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out") 425- endif() 426- 427- generate_out(INPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c" 428- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" 429- DEPENDS pnglibconf_c) 430- add_custom_target(pnglibconf_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out") 431- 432- # Generate pnglibconf.h 433- generate_source(OUTPUT "pnglibconf.h" 434- DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" pnglibconf_out 435- ${PNGLIBCONF_H_EXTRA_DEPENDS}) 436- add_custom_target(pnglibconf_h DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h") 437- 438- generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/intprefix.c" 439- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out" 440- DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" pnglibconf_h) 441- add_custom_target(scripts_intprefix_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out") 442- 443- generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/prefix.c" 444- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" 445- DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h" 446- "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h" 447- "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" pnglibconf_out) 448- add_custom_target(scripts_prefix_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out") 449- 450- # Generate pngprefix.h 451- generate_source(OUTPUT "pngprefix.h" 452- DEPENDS ${PNGPREFIX_H_EXTRA_DEPENDS}) 453- add_custom_target(pngprefix_h DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h") 454- 455- generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/sym.c" 456- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" 457- DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" pnglibconf_h) 458- add_custom_target(scripts_sym_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out") 459- 460- generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.c" 461- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" 462- DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h" 463- "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h" 464- "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt") 465- add_custom_target(scripts_symbols_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out") 466- 467- generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/vers.c" 468- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out" 469- DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h" 470- "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h" 471- "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" pnglibconf_h) 472- add_custom_target(scripts_vers_out DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out") 473- 474- generate_chk(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" 475- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk" 476- DEPENDS scripts_symbols_out 477- "${CMAKE_CURRENT_BINARY_DIR}/scripts/checksym.awk" 478- "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.def") 479- 480- add_custom_target(scripts_symbols_chk 481- DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk") 482- 483- generate_copy(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" 484- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym" 485- DEPENDS scripts_sym_out) 486- generate_copy(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out" 487- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers" 488- DEPENDS scripts_vers_out) 489- 490- add_custom_target(genvers 491- DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers") 492- add_custom_target(gensym 493- DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym") 494- 495- add_custom_target("genprebuilt" 496- COMMAND "${CMAKE_COMMAND}" 497- "-DOUTPUT=scripts/pnglibconf.h.prebuilt" 498- -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake" 499- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") 500- 501- # A single target handles generation of all generated files. 502- add_custom_target(genfiles 503- DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym" gensym 504- "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers" genvers 505- "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c" pnglibconf_c 506- "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" pnglibconf_h 507- "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" pnglibconf_out 508- "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h" pngprefix_h 509- "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out" scripts_intprefix_out 510- "${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c" scripts_pnglibconf_c 511- "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" scripts_prefix_out 512- "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" scripts_sym_out 513- "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk" scripts_symbols_chk 514- "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" scripts_symbols_out 515- "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out" scripts_vers_out) 516-endif(NOT AWK OR ANDROID OR IOS) 517- 518-# List the source code files. 519-set(libpng_public_hdrs 520- png.h 521- pngconf.h 522- "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" 523-) 524-set(libpng_private_hdrs 525- pngpriv.h 526- pngdebug.h 527- pnginfo.h 528- pngstruct.h 529-) 530-if(AWK AND NOT ANDROID AND NOT IOS) 531- list(APPEND libpng_private_hdrs "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h") 532-endif() 533-set(libpng_sources 534- ${libpng_public_hdrs} 535- ${libpng_private_hdrs} 536- png.c 537- pngerror.c 538- pngget.c 539- pngmem.c 540- pngpread.c 541- pngread.c 542- pngrio.c 543- pngrtran.c 544- pngrutil.c 545- pngset.c 546- pngtrans.c 547- pngwio.c 548- pngwrite.c 549- pngwtran.c 550- pngwutil.c 551- ${libpng_arm_sources} 552- ${libpng_intel_sources} 553- ${libpng_mips_sources} 554- ${libpng_powerpc_sources} 555-) 556-set(pngtest_sources 557- pngtest.c 558-) 559-set(pngvalid_sources 560- contrib/libtests/pngvalid.c 561-) 562-set(pngstest_sources 563- contrib/libtests/pngstest.c 564-) 565-set(pngunknown_sources 566- contrib/libtests/pngunknown.c 567-) 568-set(pngimage_sources 569- contrib/libtests/pngimage.c 570-) 571-set(pngfix_sources 572- contrib/tools/pngfix.c 573-) 574-set(png_fix_itxt_sources 575- contrib/tools/png-fix-itxt.c 576-) 577- 578-if(MSVC) 579- add_definitions(-D_CRT_SECURE_NO_DEPRECATE) 580-endif() 581- 582-if(PNG_DEBUG) 583- add_definitions(-DPNG_DEBUG) 584-endif() 585- 586-# Now build our target. 587-include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIRS}) 588- 589-unset(PNG_LIB_TARGETS) 590- 591-if(PNG_SHARED) 592- add_library(png SHARED ${libpng_sources}) 593- set(PNG_LIB_TARGETS png) 594- set_target_properties(png PROPERTIES OUTPUT_NAME ${PNG_LIB_NAME}) 595- add_dependencies(png genfiles) 596- if(MSVC) 597- # MVC does not append 'lib'. Do it here, to have consistent name. 598- set_target_properties(png PROPERTIES PREFIX "lib") 599- set_target_properties(png PROPERTIES IMPORT_PREFIX "lib") 600- endif() 601- target_link_libraries(png ${ZLIB_LIBRARIES} ${M_LIBRARY}) 602- 603- if(UNIX AND AWK) 604- if(HAVE_LD_VERSION_SCRIPT) 605- set_target_properties(png PROPERTIES 606- LINK_FLAGS "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'") 607- elseif(HAVE_SOLARIS_LD_VERSION_SCRIPT) 608- set_target_properties(png PROPERTIES 609- LINK_FLAGS "-Wl,-M -Wl,'${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'") 610- endif() 611- endif() 612-endif() 613- 614-if(PNG_STATIC) 615- # does not work without changing name 616- set(PNG_LIB_NAME_STATIC png_static) 617- add_library(png_static STATIC ${libpng_sources}) 618- add_dependencies(png_static genfiles) 619- # MSVC doesn't use a different file extension for shared vs. static 620- # libs. We are able to change OUTPUT_NAME to remove the _static 621- # for all other platforms. 622- if(NOT MSVC) 623- set_target_properties(png_static PROPERTIES 624- OUTPUT_NAME "${PNG_LIB_NAME}" 625- CLEAN_DIRECT_OUTPUT 1) 626- else() 627- set_target_properties(png_static PROPERTIES 628- OUTPUT_NAME "${PNG_LIB_NAME}_static" 629- CLEAN_DIRECT_OUTPUT 1) 630- endif() 631- list(APPEND PNG_LIB_TARGETS png_static) 632- if(MSVC) 633- # MSVC does not append 'lib'. Do it here, to have consistent name. 634- set_target_properties(png_static PROPERTIES PREFIX "lib") 635- endif() 636- target_link_libraries(png_static ${ZLIB_LIBRARIES} ${M_LIBRARY}) 637-endif() 638- 639-if(PNG_FRAMEWORK) 640- set(PNG_LIB_NAME_FRAMEWORK png_framework) 641- add_library(png_framework SHARED ${libpng_sources}) 642- add_dependencies(png_framework genfiles) 643- list(APPEND PNG_LIB_TARGETS png_framework) 644- set_target_properties(png_framework PROPERTIES 645- FRAMEWORK TRUE 646- FRAMEWORK_VERSION ${PNGLIB_VERSION} 647- MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PNGLIB_MAJOR}.${PNGLIB_MINOR} 648- MACOSX_FRAMEWORK_BUNDLE_VERSION ${PNGLIB_VERSION} 649- MACOSX_FRAMEWORK_IDENTIFIER org.libpng.libpng 650- XCODE_ATTRIBUTE_INSTALL_PATH "@rpath" 651- PUBLIC_HEADER "${libpng_public_hdrs}" 652- OUTPUT_NAME png) 653- target_link_libraries(png_framework ${ZLIB_LIBRARIES} ${M_LIBRARY}) 654-endif() 655- 656-if(NOT PNG_LIB_TARGETS) 657- message(SEND_ERROR "No library variant selected to build. " 658- "Please enable at least one of the following options: " 659- "PNG_STATIC, PNG_SHARED, PNG_FRAMEWORK") 660-endif() 661- 662-if(PNG_SHARED AND WIN32) 663- set_target_properties(png PROPERTIES 664- DEFINE_SYMBOL PNG_BUILD_DLL) 665-endif() 666- 667-function(png_add_test) 668- set(options) 669- set(oneValueArgs NAME COMMAND) 670- set(multiValueArgs OPTIONS FILES) 671- cmake_parse_arguments(_PAT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 672- 673- if(NOT _PAT_NAME) 674- message(FATAL_ERROR "png_add_test: Missing NAME argument") 675- endif() 676- if(NOT _PAT_COMMAND) 677- message(FATAL_ERROR "png_add_test: Missing COMMAND argument") 678- endif() 679- 680- set(TEST_OPTIONS "${_PAT_OPTIONS}") 681- set(TEST_FILES "${_PAT_FILES}") 682- 683- configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/test.cmake.in" 684- "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake" 685- @ONLY) 686- add_test(NAME "${_PAT_NAME}" 687- COMMAND "${CMAKE_COMMAND}" 688- "-DLIBPNG=$<TARGET_FILE:png>" 689- "-DTEST_COMMAND=$<TARGET_FILE:${_PAT_COMMAND}>" 690- -P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake") 691-endfunction() 692- 693-if(PNG_TESTS AND PNG_SHARED) 694- # Find test PNG files by globbing, but sort lists to ensure 695- # consistency between different filesystems. 696- file(GLOB PNGSUITE_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/*.png") 697- list(SORT PNGSUITE_PNGS) 698- file(GLOB TEST_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/testpngs/*.png") 699- list(SORT TEST_PNGS) 700- 701- set(PNGTEST_PNG "${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png") 702- 703- add_executable(pngtest ${pngtest_sources}) 704- target_link_libraries(pngtest png) 705- 706- png_add_test(NAME pngtest 707- COMMAND pngtest 708- FILES "${PNGTEST_PNG}") 709- 710- add_executable(pngvalid ${pngvalid_sources}) 711- target_link_libraries(pngvalid png) 712- 713- png_add_test(NAME pngvalid-gamma-16-to-8 714- COMMAND pngvalid 715- OPTIONS --gamma-16-to-8) 716- png_add_test(NAME pngvalid-gamma-alpha-mode 717- COMMAND pngvalid 718- OPTIONS --gamma-alpha-mode) 719- png_add_test(NAME pngvalid-gamma-background 720- COMMAND pngvalid 721- OPTIONS --gamma-background) 722- png_add_test(NAME pngvalid-gamma-expand16-alpha-mode 723- COMMAND pngvalid 724- OPTIONS --gamma-alpha-mode --expand16) 725- png_add_test(NAME pngvalid-gamma-expand16-background 726- COMMAND pngvalid 727- OPTIONS --gamma-background --expand16) 728- png_add_test(NAME pngvalid-gamma-expand16-transform 729- COMMAND pngvalid 730- OPTIONS --gamma-transform --expand16) 731- png_add_test(NAME pngvalid-gamma-sbit 732- COMMAND pngvalid 733- OPTIONS --gamma-sbit) 734- png_add_test(NAME pngvalid-gamma-threshold 735- COMMAND pngvalid 736- OPTIONS --gamma-threshold) 737- png_add_test(NAME pngvalid-gamma-transform 738- COMMAND pngvalid 739- OPTIONS --gamma-transform) 740- png_add_test(NAME pngvalid-progressive-interlace-standard 741- COMMAND pngvalid 742- OPTIONS --standard --progressive-read --interlace) 743- png_add_test(NAME pngvalid-progressive-size 744- COMMAND pngvalid 745- OPTIONS --size --progressive-read) 746- png_add_test(NAME pngvalid-progressive-standard 747- COMMAND pngvalid 748- OPTIONS --standard --progressive-read) 749- png_add_test(NAME pngvalid-standard 750- COMMAND pngvalid 751- OPTIONS --standard) 752- png_add_test(NAME pngvalid-transform 753- COMMAND pngvalid 754- OPTIONS --transform) 755- 756- add_executable(pngstest ${pngstest_sources}) 757- target_link_libraries(pngstest png) 758- 759- foreach(gamma_type 1.8 linear none sRGB) 760- foreach(alpha_type none alpha) 761- set(PNGSTEST_FILES) 762- foreach(test_png ${TEST_PNGS}) 763- string(REGEX MATCH ".*-linear[-.].*" TEST_PNG_LINEAR "${test_png}") 764- string(REGEX MATCH ".*-sRGB[-.].*" TEST_PNG_SRGB "${test_png}") 765- string(REGEX MATCH ".*-1.8[-.].*" TEST_PNG_G18 "${test_png}") 766- string(REGEX MATCH ".*-alpha-.*" TEST_PNG_ALPHA "${test_png}") 767- 768- set(TEST_PNG_VALID TRUE) 769- 770- if(TEST_PNG_ALPHA) 771- if(NOT "${alpha_type}" STREQUAL "alpha") 772- set(TEST_PNG_VALID FALSE) 773- endif() 774- else() 775- if("${alpha_type}" STREQUAL "alpha") 776- set(TEST_PNG_VALID FALSE) 777- endif() 778- endif() 779- 780- if(TEST_PNG_LINEAR) 781- if(NOT "${gamma_type}" STREQUAL "linear") 782- set(TEST_PNG_VALID FALSE) 783- endif() 784- elseif(TEST_PNG_SRGB) 785- if(NOT "${gamma_type}" STREQUAL "sRGB") 786- set(TEST_PNG_VALID FALSE) 787- endif() 788- elseif(TEST_PNG_G18) 789- if(NOT "${gamma_type}" STREQUAL "1.8") 790- set(TEST_PNG_VALID FALSE) 791- endif() 792- else() 793- if(NOT "${gamma_type}" STREQUAL "none") 794- set(TEST_PNG_VALID FALSE) 795- endif() 796- endif() 797- 798- if(TEST_PNG_VALID) 799- list(APPEND PNGSTEST_FILES "${test_png}") 800- endif() 801- endforeach() 802- # Should already be sorted, but sort anyway to be certain. 803- list(SORT PNGSTEST_FILES) 804- png_add_test(NAME pngstest-${gamma_type}-${alpha_type} 805- COMMAND pngstest 806- OPTIONS --tmpfile "${gamma_type}-${alpha_type}-" --log 807- FILES ${PNGSTEST_FILES}) 808- endforeach() 809- endforeach() 810- 811- add_executable(pngunknown ${pngunknown_sources}) 812- target_link_libraries(pngunknown png) 813- 814- png_add_test(NAME pngunknown-discard 815- COMMAND pngunknown 816- OPTIONS --strict default=discard 817- FILES "${PNGTEST_PNG}") 818- png_add_test(NAME pngunknown-IDAT 819- COMMAND pngunknown 820- OPTIONS --strict default=discard IDAT=save 821- FILES "${PNGTEST_PNG}") 822- png_add_test(NAME pngunknown-if-safe 823- COMMAND pngunknown 824- OPTIONS --strict default=if-safe 825- FILES "${PNGTEST_PNG}") 826- png_add_test(NAME pngunknown-sAPI 827- COMMAND pngunknown 828- OPTIONS --strict bKGD=save cHRM=save gAMA=save all=discard iCCP=save sBIT=save sRGB=save 829- FILES "${PNGTEST_PNG}") 830- png_add_test(NAME pngunknown-save 831- COMMAND pngunknown 832- OPTIONS --strict default=save 833- FILES "${PNGTEST_PNG}") 834- png_add_test(NAME pngunknown-sTER 835- COMMAND pngunknown 836- OPTIONS --strict sTER=if-safe 837- FILES "${PNGTEST_PNG}") 838- png_add_test(NAME pngunknown-vpAg 839- COMMAND pngunknown 840- OPTIONS --strict vpAg=if-safe 841- FILES "${PNGTEST_PNG}") 842- 843- add_executable(pngimage ${pngimage_sources}) 844- target_link_libraries(pngimage png) 845- 846- png_add_test(NAME pngimage-quick 847- COMMAND pngimage 848- OPTIONS --list-combos --log 849- FILES ${PNGSUITE_PNGS}) 850- png_add_test(NAME pngimage-full 851- COMMAND pngimage 852- OPTIONS --exhaustive --list-combos --log 853- FILES ${PNGSUITE_PNGS}) 854-endif() 855- 856-if(PNG_SHARED AND PNG_EXECUTABLES) 857- add_executable(pngfix ${pngfix_sources}) 858- target_link_libraries(pngfix png) 859- set(PNG_BIN_TARGETS pngfix) 860- 861- add_executable(png-fix-itxt ${png_fix_itxt_sources}) 862- target_link_libraries(png-fix-itxt ${ZLIB_LIBRARIES} ${M_LIBRARY}) 863- list(APPEND PNG_BIN_TARGETS png-fix-itxt) 864-endif() 865- 866-# Creates a symlink from src to dest (if possible), or, alternatively, 867-# copies src to dest if different. 868-include(CMakeParseArguments) 869-function(create_symlink DEST_FILE) 870- cmake_parse_arguments(S "" "FILE;TARGET" "" ${ARGN}) 871- 872- if(NOT S_TARGET AND NOT S_FILE) 873- message(FATAL_ERROR "create_symlink: Missing TARGET or FILE argument") 874- endif() 875- 876- if(S_TARGET AND S_FILE) 877- message(FATAL_ERROR "create_symlink: " 878- "Both source file ${S_FILE} and build target ${S_TARGET} arguments are present; " 879- "can only have one") 880- endif() 881- 882- if(S_FILE) 883- # If we don't need to symlink something that's coming from a build target, 884- # we can go ahead and symlink/copy at configure time. 885- if(CMAKE_HOST_WIN32 AND NOT CYGWIN) 886- execute_process(COMMAND "${CMAKE_COMMAND}" 887- -E copy_if_different 888- ${S_FILE} ${DEST_FILE} 889- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") 890- else() 891- execute_process(COMMAND "${CMAKE_COMMAND}" 892- -E create_symlink 893- ${S_FILE} ${DEST_FILE} 894- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") 895- endif() 896- endif() 897- 898- if(S_TARGET) 899- # We need to use generator expressions, which can be a bit tricky. 900- # For simplicity, make the symlink a POST_BUILD step, and use the TARGET 901- # signature of add_custom_command. 902- if(CMAKE_HOST_WIN32 AND NOT CYGWIN) 903- add_custom_command(TARGET ${S_TARGET} 904- POST_BUILD 905- COMMAND "${CMAKE_COMMAND}" 906- -E copy_if_different 907- $<TARGET_LINKER_FILE_NAME:${S_TARGET}> 908- $<TARGET_LINKER_FILE_DIR:${S_TARGET}>/${DEST_FILE}) 909- else() 910- add_custom_command(TARGET ${S_TARGET} 911- POST_BUILD 912- COMMAND "${CMAKE_COMMAND}" 913- -E create_symlink 914- $<TARGET_LINKER_FILE_NAME:${S_TARGET}> 915- $<TARGET_LINKER_FILE_DIR:${S_TARGET}>/${DEST_FILE}) 916- endif() 917- endif() 918-endfunction() 919- 920-# Create source generation scripts. 921-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genchk.cmake.in 922- ${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake 923- @ONLY) 924-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genout.cmake.in 925- ${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake 926- @ONLY) 927-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/gensrc.cmake.in 928- ${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake 929- @ONLY) 930- 931-# libpng is a library so default to 'lib' 932-if(NOT DEFINED CMAKE_INSTALL_LIBDIR) 933- set(CMAKE_INSTALL_LIBDIR lib) 934-endif() 935- 936-# Create pkgconfig files. 937-# We use the same files like ./configure, so we have to set its vars. 938-# Only do this on Windows for Cygwin - the files don't make much sense 939-# outside of a UNIX look-alike. 940-if(NOT WIN32 OR CYGWIN OR MINGW) 941- set(prefix ${CMAKE_INSTALL_PREFIX}) 942- set(exec_prefix ${CMAKE_INSTALL_PREFIX}) 943- set(libdir ${CMAKE_INSTALL_FULL_LIBDIR}) 944- set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}) 945- set(LIBS "-lz -lm") 946- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in 947- ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc 948- @ONLY) 949- create_symlink(libpng.pc FILE ${PNGLIB_NAME}.pc) 950- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in 951- ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config 952- @ONLY) 953- create_symlink(libpng-config FILE ${PNGLIB_NAME}-config) 954-endif() 955- 956-# Set up links. 957-if(PNG_SHARED) 958- set_target_properties(png PROPERTIES 959- VERSION ${PNGLIB_SHARED_VERSION} 960- SOVERSION ${PNGLIB_SHARED_SOVERSION} 961- CLEAN_DIRECT_OUTPUT 1) 962-endif() 963- 964-# Install. 965-if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL) 966- install(TARGETS ${PNG_LIB_TARGETS} 967- EXPORT libpng 968- RUNTIME DESTINATION bin 969- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 970- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 971- FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}) 972- 973- if(PNG_SHARED) 974- # Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin 975- if(CYGWIN OR MINGW) 976- create_symlink(libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} TARGET png) 977- install(FILES $<TARGET_LINKER_FILE_DIR:png>/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} 978- DESTINATION ${CMAKE_INSTALL_LIBDIR}) 979- endif() 980- 981- if(NOT WIN32) 982- create_symlink(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png) 983- install(FILES $<TARGET_LINKER_FILE_DIR:png>/libpng${CMAKE_SHARED_LIBRARY_SUFFIX} 984- DESTINATION ${CMAKE_INSTALL_LIBDIR}) 985- endif() 986- endif() 987- 988- if(PNG_STATIC) 989- if(NOT WIN32 OR CYGWIN OR MINGW) 990- create_symlink(libpng${CMAKE_STATIC_LIBRARY_SUFFIX} TARGET png_static) 991- install(FILES $<TARGET_LINKER_FILE_DIR:png_static>/libpng${CMAKE_STATIC_LIBRARY_SUFFIX} 992- DESTINATION ${CMAKE_INSTALL_LIBDIR}) 993- endif() 994- endif() 995-endif() 996- 997-if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL) 998- install(FILES ${libpng_public_hdrs} 999- DESTINATION include) 1000- install(FILES ${libpng_public_hdrs} 1001- DESTINATION include/${PNGLIB_NAME}) 1002-endif() 1003-if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL) 1004- if(NOT WIN32 OR CYGWIN OR MINGW) 1005- install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config 1006- DESTINATION bin) 1007- install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config 1008- DESTINATION bin) 1009- endif() 1010-endif() 1011- 1012-if(NOT SKIP_INSTALL_PROGRAMS AND NOT SKIP_INSTALL_ALL) 1013- install(TARGETS ${PNG_BIN_TARGETS} 1014- RUNTIME DESTINATION bin) 1015-endif() 1016- 1017-if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL) 1018- # Install the man pages. 1019- install(FILES libpng.3 libpngpf.3 1020- DESTINATION ${CMAKE_INSTALL_MANDIR}/man3) 1021- install(FILES png.5 1022- DESTINATION ${CMAKE_INSTALL_MANDIR}/man5) 1023- # Install the pkg-config files. 1024- if(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW) 1025- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc 1026- DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) 1027- install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config 1028- DESTINATION ${CMAKE_INSTALL_BINDIR}) 1029- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc 1030- DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) 1031- install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config 1032- DESTINATION ${CMAKE_INSTALL_BINDIR}) 1033- endif() 1034-endif() 1035- 1036-# Create an export file that CMake users can include() to import our targets. 1037-if(NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL) 1038- install(EXPORT libpng 1039- DESTINATION lib/libpng 1040- FILE lib${PNG_LIB_NAME}.cmake) 1041-endif() 1042- 1043-# TODO: Create MSVC import lib for MinGW-compiled shared lib. 1044-# pexports libpng.dll > libpng.def 1045-# lib /def:libpng.def /machine:x86 1046+cmake_minimum_required(VERSION 3.16.5) 1047+ 1048+set(LibpngInc "${PROJECT_SOURCE_DIR}/third_party/libpng") 1049+set(LibpngSrc "${PROJECT_SOURCE_DIR}/third_party/libpng") 1050+ 1051+include_directories(${LibpngInc}) 1052+message(${LibpngSrc}) 1053+add_library(libpng STATIC 1054+ ${LibpngSrc}/png.c 1055+ ${LibpngSrc}/pngerror.c 1056+ ${LibpngSrc}/pngget.c 1057+ ${LibpngSrc}/pngmem.c 1058+ ${LibpngSrc}/pngpread.c 1059+ ${LibpngSrc}/pngread.c 1060+ ${LibpngSrc}/pngrio.c 1061+ ${LibpngSrc}/pngrtran.c 1062+ ${LibpngSrc}/pngrutil.c 1063+ ${LibpngSrc}/pngset.c 1064+ ${LibpngSrc}/pngtrans.c 1065+ ${LibpngSrc}/pngwio.c 1066+ ${LibpngSrc}/pngwrite.c 1067+ ${LibpngSrc}/pngwtran.c 1068+ ${LibpngSrc}/pngwutil.c 1069+ ) 1070+target_link_libraries(libpng PUBLIC zlib) 1071+target_include_directories(libpng PUBLIC ${LibpngInc}) 1072