fukasawa e60969
# CMakeLists.txt
fukasawa e60969
fukasawa e60969
# Copyright (C) 2007-2015 Glenn Randers-Pehrson
fukasawa e60969
fukasawa e60969
# This code is released under the libpng license.
fukasawa e60969
# For conditions of distribution and use, see the disclaimer
fukasawa e60969
# and license in png.h
fukasawa e60969
fukasawa e60969
cmake_minimum_required(VERSION 2.4.4)
fukasawa e60969
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
fukasawa e60969
fukasawa e60969
set(CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo")
fukasawa e60969
fukasawa e60969
project(libpng C)
fukasawa e60969
enable_testing()
fukasawa e60969
fukasawa e60969
set(PNGLIB_MAJOR 1)
fukasawa e60969
set(PNGLIB_MINOR 6)
fukasawa e60969
set(PNGLIB_RELEASE 21)
fukasawa e60969
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
fukasawa e60969
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
fukasawa e60969
fukasawa e60969
# needed packages
fukasawa e60969
find_package(ZLIB REQUIRED)
fukasawa e60969
include_directories(${ZLIB_INCLUDE_DIR})
fukasawa e60969
fukasawa e60969
if(NOT WIN32)
fukasawa e60969
  find_library(M_LIBRARY
fukasawa e60969
    NAMES m
fukasawa e60969
    PATHS /usr/lib /usr/local/lib
fukasawa e60969
  )
fukasawa e60969
  if(NOT M_LIBRARY)
fukasawa e60969
    message(STATUS "math lib 'libm' not found; floating point support disabled")
fukasawa e60969
  endif()
fukasawa e60969
else()
fukasawa e60969
  # not needed on windows
fukasawa e60969
  set(M_LIBRARY "")
fukasawa e60969
endif()
fukasawa e60969
fukasawa e60969
# COMMAND LINE OPTIONS
fukasawa e60969
option(PNG_SHARED "Build shared lib" ON)
fukasawa e60969
option(PNG_STATIC "Build static lib" ON)
fukasawa e60969
option(PNG_TESTS  "Build libpng tests" ON)
fukasawa e60969
fukasawa e60969
# Many more configuration options could be added here
fukasawa e60969
option(PNG_FRAMEWORK "Build OS X framework" OFF)
fukasawa e60969
option(PNG_DEBUG     "Build with debug output" OFF)
fukasawa e60969
option(PNGARG        "Disable ANSI-C prototypes" OFF)
fukasawa e60969
fukasawa e60969
# SET LIBNAME
fukasawa e60969
set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
fukasawa e60969
fukasawa e60969
# to distinguish between debug and release lib
fukasawa e60969
set(CMAKE_DEBUG_POSTFIX "d")
fukasawa e60969
fukasawa e60969
# Use the prebuilt pnglibconf.h file from the scripts folder
fukasawa e60969
# TODO: fix this by building with awk; without this no cmake build can be
fukasawa e60969
# configured directly (to do so indirectly use your local awk to build a
fukasawa e60969
# pnglibconf.h in the build directory.)
fukasawa e60969
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
fukasawa e60969
               ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h)
fukasawa e60969
include_directories(${CMAKE_CURRENT_BINARY_DIR})
fukasawa e60969
fukasawa e60969
# OUR SOURCES
fukasawa e60969
set(libpng_public_hdrs
fukasawa e60969
  png.h
fukasawa e60969
  pngconf.h
fukasawa e60969
  ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h
fukasawa e60969
)
fukasawa e60969
set(libpng_sources
fukasawa e60969
  ${libpng_public_hdrs}
fukasawa e60969
  pngdebug.h
fukasawa e60969
  pnginfo.h
fukasawa e60969
  pngpriv.h
fukasawa e60969
  pngstruct.h
fukasawa e60969
  png.c
fukasawa e60969
  pngerror.c
fukasawa e60969
  pngget.c
fukasawa e60969
  pngmem.c
fukasawa e60969
  pngpread.c
fukasawa e60969
  pngread.c
fukasawa e60969
  pngrio.c
fukasawa e60969
  pngrtran.c
fukasawa e60969
  pngrutil.c
fukasawa e60969
  pngset.c
fukasawa e60969
  pngtrans.c
fukasawa e60969
  pngwio.c
fukasawa e60969
  pngwrite.c
fukasawa e60969
  pngwtran.c
fukasawa e60969
  pngwutil.c
fukasawa e60969
)
fukasawa e60969
set(pngtest_sources
fukasawa e60969
  pngtest.c
fukasawa e60969
)
fukasawa e60969
set(pngvalid_sources
fukasawa e60969
  contrib/libtests/pngvalid.c
fukasawa e60969
)
fukasawa e60969
set(pngstest_sources
fukasawa e60969
  contrib/libtests/pngstest.c
fukasawa e60969
)
fukasawa e60969
# SOME NEEDED DEFINITIONS
fukasawa e60969
fukasawa e60969
if(MSVC)
fukasawa e60969
  add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
fukasawa e60969
endif(MSVC)
fukasawa e60969
fukasawa e60969
if(PNG_DEBUG)
fukasawa e60969
  add_definitions(-DPNG_DEBUG)
fukasawa e60969
endif()
fukasawa e60969
fukasawa e60969
# NOW BUILD OUR TARGET
fukasawa e60969
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR})
fukasawa e60969
fukasawa e60969
unset(PNG_LIB_TARGETS)
fukasawa e60969
fukasawa e60969
if(PNG_SHARED)
fukasawa e60969
  add_library(${PNG_LIB_NAME} SHARED ${libpng_sources})
fukasawa e60969
  set(PNG_LIB_TARGETS ${PNG_LIB_NAME})
fukasawa e60969
  if(MSVC)
fukasawa e60969
    # msvc does not append 'lib' - do it here to have consistent name
fukasawa e60969
    set_target_properties(${PNG_LIB_NAME} PROPERTIES PREFIX "lib")
fukasawa e60969
    set_target_properties(${PNG_LIB_NAME} PROPERTIES IMPORT_PREFIX "lib")
fukasawa e60969
  endif()
fukasawa e60969
  target_link_libraries(${PNG_LIB_NAME} ${ZLIB_LIBRARY} ${M_LIBRARY})
fukasawa e60969
endif()
fukasawa e60969
fukasawa e60969
if(PNG_STATIC)
fukasawa e60969
  # does not work without changing name
fukasawa e60969
  set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME}_static)
fukasawa e60969
  add_library(${PNG_LIB_NAME_STATIC} STATIC ${libpng_sources})
fukasawa e60969
  list(APPEND PNG_LIB_TARGETS ${PNG_LIB_NAME_STATIC})
fukasawa e60969
  if(MSVC)
fukasawa e60969
    # msvc does not append 'lib' - do it here to have consistent name
fukasawa e60969
    set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES PREFIX "lib")
fukasawa e60969
  endif()
fukasawa e60969
  target_link_libraries(${PNG_LIB_NAME_STATIC} ${ZLIB_LIBRARY} ${M_LIBRARY})
fukasawa e60969
endif()
fukasawa e60969
fukasawa e60969
if(PNG_FRAMEWORK)
fukasawa e60969
  set(PNG_LIB_NAME_FRAMEWORK ${PNG_LIB_NAME}_framework)
fukasawa e60969
  add_library(${PNG_LIB_NAME_FRAMEWORK} SHARED ${libpng_sources})
fukasawa e60969
  list(APPEND PNG_LIB_TARGETS ${PNG_LIB_NAME_FRAMEWORK})
fukasawa e60969
  set_target_properties(${PNG_LIB_NAME_FRAMEWORK} PROPERTIES
fukasawa e60969
    FRAMEWORK TRUE
fukasawa e60969
    FRAMEWORK_VERSION ${PNGLIB_VERSION}
fukasawa e60969
    MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PNGLIB_MAJOR}.${PNGLIB_MINOR}
fukasawa e60969
    MACOSX_FRAMEWORK_BUNDLE_VERSION ${PNGLIB_VERSION}
fukasawa e60969
    MACOSX_FRAMEWORK_IDENTIFIER org.libpng.libpng
fukasawa e60969
    XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
fukasawa e60969
    PUBLIC_HEADER "${libpng_public_hdrs}"
fukasawa e60969
    OUTPUT_NAME png)
fukasawa e60969
  target_link_libraries(${PNG_LIB_NAME_FRAMEWORK} ${ZLIB_LIBRARY} ${M_LIBRARY})
fukasawa e60969
endif()
fukasawa e60969
fukasawa e60969
if(NOT PNG_LIB_TARGETS)
fukasawa e60969
  message(SEND_ERROR
fukasawa e60969
    "No library variant selected to build. "
fukasawa e60969
    "Please enable at least one of the following options: "
fukasawa e60969
    " PNG_STATIC, PNG_SHARED, PNG_FRAMEWORK")
fukasawa e60969
endif()
fukasawa e60969
fukasawa e60969
if(PNG_SHARED AND WIN32)
fukasawa e60969
  set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
fukasawa e60969
endif()
fukasawa e60969
fukasawa e60969
if(PNG_TESTS AND PNG_SHARED)
fukasawa e60969
  # does not work with msvc due to png_lib_ver issue
fukasawa e60969
  add_executable(pngtest ${pngtest_sources})
fukasawa e60969
  target_link_libraries(pngtest ${PNG_LIB_NAME})
fukasawa e60969
  add_test(pngtest ./pngtest ${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png)
fukasawa e60969
  #
fukasawa e60969
  add_executable(pngvalid ${pngvalid_sources})
fukasawa e60969
  target_link_libraries(pngvalid ${PNG_LIB_NAME})
fukasawa e60969
  add_test(pngvalid ./pngvalid)
fukasawa e60969
  add_executable(pngstest ${pngstest_sources})
fukasawa e60969
  target_link_libraries(pngstest ${PNG_LIB_NAME})
fukasawa e60969
  add_test(pngstest ./pngstest
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g01.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g02.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g04.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g08.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g16.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn2c08.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn2c16.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p01.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p02.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p04.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p08.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn4a08.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn4a16.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn6a08.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn6a16.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn0g01.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn0g02.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn0g04.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn2c16.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn3p08.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbgn2c16.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbgn3p08.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbrn2c08.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbwn0g16.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbwn3p08.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbyn3p08.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp0n0g08.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp0n2c08.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp0n3p08.png
fukasawa e60969
    ${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp1n3p08.png
fukasawa e60969
  )
fukasawa e60969
endif()
fukasawa e60969
fukasawa e60969
# Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set
fukasawa e60969
IF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
fukasawa e60969
  SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "lib")
fukasawa e60969
ENDIF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
fukasawa e60969
fukasawa e60969
# Set a variable with CMake code which:
fukasawa e60969
# Creates a symlink from src to dest (if possible) or alternatively
fukasawa e60969
# copies if different.
fukasawa e60969
macro(CREATE_SYMLINK SRC_FILE DEST_FILE)
fukasawa e60969
  FILE(REMOVE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
fukasawa e60969
  if(WIN32 AND NOT CYGWIN AND NOT MSYS)
fukasawa e60969
    ADD_CUSTOM_COMMAND(
fukasawa e60969
        OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}   ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
fukasawa e60969
        COMMAND ${CMAKE_COMMAND} -E copy_if_different  "${SRC_FILE}" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}
fukasawa e60969
        COMMAND ${CMAKE_COMMAND} -E copy_if_different  "${SRC_FILE}" ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
fukasawa e60969
        DEPENDS ${PNG_LIB_TARGETS}
fukasawa e60969
        )
fukasawa e60969
    ADD_CUSTOM_TARGET(${DEST_FILE}_COPY ALL DEPENDS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
fukasawa e60969
  else(WIN32 AND NOT CYGWIN AND NOT MSYS)
fukasawa e60969
    get_filename_component(LINK_TARGET "${SRC_FILE}" NAME)
fukasawa e60969
    execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
fukasawa e60969
    execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${LINK_TARGET}" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
fukasawa e60969
    execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${LINK_TARGET}" ${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
fukasawa e60969
  endif(WIN32 AND NOT CYGWIN AND NOT MSYS)
fukasawa e60969
endmacro()
fukasawa e60969
fukasawa e60969
# libpng is a library so default to 'lib'
fukasawa e60969
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
fukasawa e60969
  set(CMAKE_INSTALL_LIBDIR lib)
fukasawa e60969
endif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
fukasawa e60969
fukasawa e60969
# CREATE PKGCONFIG FILES
fukasawa e60969
# we use the same files like ./configure, so we have to set its vars
fukasawa e60969
# Only do this on Windows for Cygwin - the files don't make much sense outside
fukasawa e60969
# a UNIX look alike
fukasawa e60969
if(NOT WIN32 OR CYGWIN OR MINGW)
fukasawa e60969
  set(prefix      ${CMAKE_INSTALL_PREFIX})
fukasawa e60969
  set(exec_prefix ${CMAKE_INSTALL_PREFIX})
fukasawa e60969
  set(libdir      ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
fukasawa e60969
  set(includedir  ${CMAKE_INSTALL_PREFIX}/include)
fukasawa e60969
  set(LIBS        "-lz -lm")
fukasawa e60969
  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in
fukasawa e60969
    ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY)
fukasawa e60969
  CREATE_SYMLINK(${PNGLIB_NAME}.pc libpng.pc)
fukasawa e60969
fukasawa e60969
  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in
fukasawa e60969
    ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY)
fukasawa e60969
  CREATE_SYMLINK(${PNGLIB_NAME}-config libpng-config)
fukasawa e60969
endif(NOT WIN32 OR CYGWIN OR MINGW)
fukasawa e60969
fukasawa e60969
# SET UP LINKS
fukasawa e60969
if(PNG_SHARED)
fukasawa e60969
  set_target_properties(${PNG_LIB_NAME} PROPERTIES
fukasawa e60969
#   VERSION 16.${PNGLIB_RELEASE}.1.6.21
fukasawa e60969
    VERSION 16.${PNGLIB_RELEASE}.0
fukasawa e60969
    SOVERSION 16
fukasawa e60969
    CLEAN_DIRECT_OUTPUT 1)
fukasawa e60969
endif()
fukasawa e60969
if(PNG_STATIC)
fukasawa e60969
  # MSVC doesn't use a different file extension for shared vs. static
fukasawa e60969
  # libs.  We are able to change OUTPUT_NAME to remove the _static
fukasawa e60969
  # for all other platforms.
fukasawa e60969
  if(NOT MSVC)
fukasawa e60969
    set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES
fukasawa e60969
      OUTPUT_NAME ${PNG_LIB_NAME}
fukasawa e60969
      CLEAN_DIRECT_OUTPUT 1)
fukasawa e60969
  endif()
fukasawa e60969
endif()
fukasawa e60969
fukasawa e60969
# If CMake > 2.4.x, we set a variable used below to export
fukasawa e60969
# targets to an export file.
fukasawa e60969
# TODO: Use VERSION_GREATER after our cmake_minimum_required >= 2.6.2
fukasawa e60969
if(CMAKE_MAJOR_VERSION GREATER 1 AND CMAKE_MINOR_VERSION GREATER 4)
fukasawa e60969
  set(PNG_EXPORT_RULE EXPORT libpng)
fukasawa e60969
elseif(CMAKE_MAJOR_VERSION GREATER 2) # future proof
fukasawa e60969
  set(PNG_EXPORT_RULE EXPORT libpng)
fukasawa e60969
endif()
fukasawa e60969
fukasawa e60969
# INSTALL
fukasawa e60969
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
fukasawa e60969
  install(TARGETS ${PNG_LIB_TARGETS}
fukasawa e60969
      ${PNG_EXPORT_RULE}
fukasawa e60969
      RUNTIME DESTINATION bin
fukasawa e60969
      LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
fukasawa e60969
      ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
fukasawa e60969
      FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR})
fukasawa e60969
fukasawa e60969
  if(PNG_SHARED)
fukasawa e60969
    # Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin
fukasawa e60969
    if(CYGWIN OR MINGW)
fukasawa e60969
       get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
fukasawa e60969
       CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
fukasawa e60969
       install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}
fukasawa e60969
         DESTINATION ${CMAKE_INSTALL_LIBDIR})
fukasawa e60969
    endif(CYGWIN OR MINGW)
fukasawa e60969
fukasawa e60969
    if(NOT WIN32)
fukasawa e60969
      get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
fukasawa e60969
      CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
fukasawa e60969
      install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
fukasawa e60969
         DESTINATION ${CMAKE_INSTALL_LIBDIR})
fukasawa e60969
    endif(NOT WIN32)
fukasawa e60969
  endif(PNG_SHARED)
fukasawa e60969
fukasawa e60969
  if(PNG_STATIC)
fukasawa e60969
    if(NOT WIN32 OR CYGWIN OR MINGW)
fukasawa e60969
      get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME_STATIC} LOCATION_${CMAKE_BUILD_TYPE})
fukasawa e60969
      CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
fukasawa e60969
      install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
fukasawa e60969
         DESTINATION ${CMAKE_INSTALL_LIBDIR})
fukasawa e60969
    endif(NOT WIN32 OR CYGWIN OR MINGW)
fukasawa e60969
 endif()
fukasawa e60969
endif()
fukasawa e60969
fukasawa e60969
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
fukasawa e60969
  install(FILES ${libpng_public_hdrs}   DESTINATION include)
fukasawa e60969
  install(FILES ${libpng_public_hdrs}   DESTINATION include/${PNGLIB_NAME})
fukasawa e60969
endif()
fukasawa e60969
if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL )
fukasawa e60969
  if(NOT WIN32 OR CYGWIN OR MINGW)
fukasawa e60969
    install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION bin)
fukasawa e60969
    install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
fukasawa e60969
            DESTINATION bin)
fukasawa e60969
  endif(NOT WIN32 OR CYGWIN OR MINGW)
fukasawa e60969
endif()
fukasawa e60969
fukasawa e60969
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
fukasawa e60969
  # Install man pages
fukasawa e60969
  if(NOT PNG_MAN_DIR)
fukasawa e60969
    set(PNG_MAN_DIR "share/man")
fukasawa e60969
  endif()
fukasawa e60969
  install(FILES libpng.3 libpngpf.3      DESTINATION ${PNG_MAN_DIR}/man3)
fukasawa e60969
  install(FILES png.5                    DESTINATION ${PNG_MAN_DIR}/man5)
fukasawa e60969
  # Install pkg-config files
fukasawa e60969
  if(NOT WIN32 OR CYGWIN OR MINGW)
fukasawa e60969
    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc
fukasawa e60969
            DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
fukasawa e60969
    install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config
fukasawa e60969
            DESTINATION bin)
fukasawa e60969
    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc
fukasawa e60969
            DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
fukasawa e60969
    install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
fukasawa e60969
            DESTINATION bin)
fukasawa e60969
  endif(NOT WIN32 OR CYGWIN OR MINGW)
fukasawa e60969
endif()
fukasawa e60969
fukasawa e60969
# On versions of CMake that support it, create an export file CMake
fukasawa e60969
# users can include() to import our targets
fukasawa e60969
if(PNG_EXPORT_RULE AND NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL )
fukasawa e60969
  install(EXPORT libpng DESTINATION lib/libpng FILE lib${PNG_LIB_NAME}.cmake)
fukasawa e60969
endif()
fukasawa e60969
fukasawa e60969
# what's with libpng-manual.txt and all the extra files?
fukasawa e60969
fukasawa e60969
# UNINSTALL
fukasawa e60969
# do we need this?
fukasawa e60969
fukasawa e60969
# DIST
fukasawa e60969
# do we need this?
fukasawa e60969
fukasawa e60969
# to create msvc import lib for mingw compiled shared lib
fukasawa e60969
# pexports libpng.dll > libpng.def
fukasawa e60969
# lib /def:libpng.def /machine:x86
fukasawa e60969