all repos — mgba @ 9de8f084ba55460b02d300c1dd8b8e6c56f691d5

mGBA Game Boy Advance Emulator

src/third-party/libpng/CMakeLists.txt (view raw)

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