2011-08-17 10:46:29 -04:00
|
|
|
# CMakeLists.txt
|
|
|
|
|
2016-01-29 10:14:41 -05:00
|
|
|
# Copyright (C) 2007,2009-2016 Glenn Randers-Pehrson
|
|
|
|
# Written by Christian Ehrlicher, 2007
|
|
|
|
# Revised by Roger Lowman, 2009-2010
|
|
|
|
# Revised by Clifford Yapp, 2011-2012
|
|
|
|
# Revised by Roger Leigh, 2016
|
2011-08-17 10:46:29 -04:00
|
|
|
|
|
|
|
# This code is released under the libpng license.
|
|
|
|
# For conditions of distribution and use, see the disclaimer
|
|
|
|
# and license in png.h
|
|
|
|
|
2016-01-28 16:58:45 -05:00
|
|
|
cmake_minimum_required(VERSION 2.8.3)
|
|
|
|
cmake_policy(VERSION 2.8.3)
|
|
|
|
|
|
|
|
# Set MacOSX @rpath usage globally.
|
|
|
|
if (POLICY CMP0020)
|
|
|
|
cmake_policy(SET CMP0020 NEW)
|
|
|
|
endif(POLICY CMP0020)
|
|
|
|
if (POLICY CMP0042)
|
|
|
|
cmake_policy(SET CMP0042 NEW)
|
|
|
|
endif(POLICY CMP0042)
|
|
|
|
# Use new variable expansion policy.
|
|
|
|
if (POLICY CMP0053)
|
|
|
|
cmake_policy(SET CMP0053 NEW)
|
|
|
|
endif(POLICY CMP0053)
|
|
|
|
if (POLICY CMP0054)
|
|
|
|
cmake_policy(SET CMP0054 NEW)
|
|
|
|
endif(POLICY CMP0054)
|
2010-02-07 19:08:50 -05:00
|
|
|
|
2013-06-05 12:07:01 -04:00
|
|
|
set(CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo")
|
|
|
|
|
2010-02-07 19:08:50 -05:00
|
|
|
project(libpng C)
|
2009-10-30 16:42:54 -04:00
|
|
|
enable_testing()
|
2006-12-07 20:16:44 -05:00
|
|
|
|
2007-05-15 17:16:34 -04:00
|
|
|
set(PNGLIB_MAJOR 1)
|
2011-11-23 16:28:01 -05:00
|
|
|
set(PNGLIB_MINOR 6)
|
2016-01-16 08:14:12 -05:00
|
|
|
set(PNGLIB_RELEASE 22)
|
2007-05-15 17:16:34 -04:00
|
|
|
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
|
|
|
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
|
2006-12-07 20:16:44 -05:00
|
|
|
|
|
|
|
# needed packages
|
|
|
|
find_package(ZLIB REQUIRED)
|
2009-08-27 16:59:40 -04:00
|
|
|
include_directories(${ZLIB_INCLUDE_DIR})
|
|
|
|
|
2007-05-15 17:16:34 -04:00
|
|
|
if(NOT WIN32)
|
2010-02-07 19:08:50 -05:00
|
|
|
find_library(M_LIBRARY
|
|
|
|
NAMES m
|
|
|
|
PATHS /usr/lib /usr/local/lib
|
|
|
|
)
|
|
|
|
if(NOT M_LIBRARY)
|
2015-03-12 07:48:01 -04:00
|
|
|
message(STATUS "math lib 'libm' not found; floating point support disabled")
|
2010-02-07 19:08:50 -05:00
|
|
|
endif()
|
2009-08-27 16:59:40 -04:00
|
|
|
else()
|
2010-02-07 19:08:50 -05:00
|
|
|
# not needed on windows
|
|
|
|
set(M_LIBRARY "")
|
2009-08-27 16:59:40 -04:00
|
|
|
endif()
|
2006-12-07 20:16:44 -05:00
|
|
|
|
2007-05-15 17:16:34 -04:00
|
|
|
# COMMAND LINE OPTIONS
|
2015-03-12 07:48:01 -04:00
|
|
|
option(PNG_SHARED "Build shared lib" ON)
|
|
|
|
option(PNG_STATIC "Build static lib" ON)
|
|
|
|
option(PNG_TESTS "Build libpng tests" ON)
|
2009-08-27 16:59:40 -04:00
|
|
|
|
2011-09-27 20:01:58 -04:00
|
|
|
# Many more configuration options could be added here
|
2015-03-12 07:48:01 -04:00
|
|
|
option(PNG_FRAMEWORK "Build OS X framework" OFF)
|
|
|
|
option(PNG_DEBUG "Build with debug output" OFF)
|
|
|
|
option(PNGARG "Disable ANSI-C prototypes" OFF)
|
2006-12-07 20:16:44 -05:00
|
|
|
|
2016-01-28 16:58:45 -05:00
|
|
|
set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names")
|
|
|
|
set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings")
|
|
|
|
|
2007-05-15 17:16:34 -04:00
|
|
|
# SET LIBNAME
|
2010-10-02 22:25:01 -04:00
|
|
|
set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
2006-12-07 20:16:44 -05:00
|
|
|
|
|
|
|
# to distinguish between debug and release lib
|
|
|
|
set(CMAKE_DEBUG_POSTFIX "d")
|
|
|
|
|
2016-01-28 16:58:45 -05:00
|
|
|
include(CheckCSourceCompiles)
|
|
|
|
option(ld-version-script "Enable linker version script" ON)
|
|
|
|
if(ld-version-script AND NOT APPLE)
|
|
|
|
# Check if LD supports linker scripts.
|
|
|
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 {
|
|
|
|
global: sym;
|
|
|
|
local: *;
|
|
|
|
};
|
|
|
|
|
|
|
|
VERS_2 {
|
|
|
|
global: sym2;
|
|
|
|
main;
|
|
|
|
} VERS_1;
|
|
|
|
")
|
|
|
|
set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
|
|
|
|
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'")
|
|
|
|
check_c_source_compiles("void sym(void) {}
|
|
|
|
void sym2(void) {}
|
|
|
|
int main(void) {return 0;}
|
|
|
|
" HAVE_LD_VERSION_SCRIPT)
|
|
|
|
if(NOT HAVE_LD_VERSION_SCRIPT)
|
|
|
|
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE} "-Wl,-M -Wl,${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
|
|
|
|
check_c_source_compiles("void sym(void) {}
|
|
|
|
void sym2(void) {}
|
|
|
|
int main(void) {return 0;}
|
|
|
|
" HAVE_SOLARIS_LD_VERSION_SCRIPT)
|
|
|
|
endif()
|
|
|
|
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})
|
|
|
|
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Find symbol prefix. Likely obsolete and unnecessary with recent
|
|
|
|
# toolchains (it's not done in many other projects).
|
|
|
|
function(symbol_prefix)
|
|
|
|
set(SYMBOL_PREFIX)
|
|
|
|
|
|
|
|
execute_process(COMMAND "${CMAKE_C_COMPILER}" "-E" "-"
|
|
|
|
INPUT_FILE /dev/null
|
|
|
|
OUTPUT_VARIABLE OUT
|
|
|
|
RESULT_VARIABLE STATUS)
|
|
|
|
|
|
|
|
if(CPP_FAIL)
|
|
|
|
message(WARNING "Failed to run the C preprocessor")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
string(REPLACE "\n" ";" OUT "${OUT}")
|
|
|
|
foreach(line ${OUT})
|
|
|
|
string(REGEX MATCH "^PREFIX=" found_match "${line}")
|
|
|
|
if(found_match)
|
|
|
|
STRING(REGEX REPLACE "^PREFIX=(.*\)" "\\1" prefix "${line}")
|
|
|
|
string(REGEX MATCH "__USER_LABEL_PREFIX__" found_match "${prefix}")
|
|
|
|
if(found_match)
|
|
|
|
STRING(REGEX REPLACE "(.*)__USER_LABEL_PREFIX__(.*)" "\\1\\2" prefix "${prefix}")
|
|
|
|
endif()
|
|
|
|
set(SYMBOL_PREFIX "${prefix}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
message(STATUS "Symbol prefix: ${SYMBOL_PREFIX}")
|
|
|
|
set(SYMBOL_PREFIX "${SYMBOL_PREFIX}" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
if(UNIX)
|
|
|
|
symbol_prefix()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
find_program(AWK NAMES gawk awk)
|
|
|
|
|
2010-10-02 22:25:01 -04:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
2006-12-07 20:16:44 -05:00
|
|
|
|
2016-01-28 16:58:45 -05:00
|
|
|
if(NOT AWK)
|
|
|
|
# No awk available to generate sources; use pre-built pnglibconf.h
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h)
|
|
|
|
add_custom_target(genfiles) # Dummy
|
|
|
|
else()
|
|
|
|
include(CMakeParseArguments)
|
|
|
|
# Generate .chk from .out with awk
|
|
|
|
# generate_chk(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
|
|
|
|
function(generate_chk)
|
|
|
|
set(options)
|
|
|
|
set(oneValueArgs INPUT OUTPUT)
|
|
|
|
set(multiValueArgs DEPENDS)
|
|
|
|
cmake_parse_arguments(_GC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
|
|
if (NOT _GC_INPUT)
|
|
|
|
message(FATAL_ERROR "Invalid arguments. generate_out requires input.")
|
|
|
|
endif()
|
|
|
|
if (NOT _GC_OUTPUT)
|
|
|
|
message(FATAL_ERROR "Invalid arguments. generate_out requires output.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_custom_command(OUTPUT "${_GC_OUTPUT}"
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
"-DINPUT=${_GC_INPUT}"
|
|
|
|
"-DOUTPUT=${_GC_OUTPUT}"
|
|
|
|
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake"
|
|
|
|
DEPENDS "${_GC_INPUT}" ${_GC_DEPENDS}
|
|
|
|
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# Generate .out from .c with awk
|
|
|
|
# generate_out(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
|
|
|
|
function(generate_out)
|
|
|
|
set(options)
|
|
|
|
set(oneValueArgs INPUT OUTPUT)
|
|
|
|
set(multiValueArgs DEPENDS)
|
|
|
|
cmake_parse_arguments(_GO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
|
|
if (NOT _GO_INPUT)
|
|
|
|
message(FATAL_ERROR "Invalid arguments. generate_out requires input.")
|
|
|
|
endif()
|
|
|
|
if (NOT _GO_OUTPUT)
|
|
|
|
message(FATAL_ERROR "Invalid arguments. generate_out requires output.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_custom_command(OUTPUT "${_GO_OUTPUT}"
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
"-DINPUT=${_GO_INPUT}"
|
|
|
|
"-DOUTPUT=${_GO_OUTPUT}"
|
|
|
|
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake"
|
|
|
|
DEPENDS "${_GO_INPUT}" ${_GO_DEPENDS}
|
|
|
|
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# Generate specific source file with awk
|
|
|
|
# generate_source(OUTPUT outputfile [DEPENDS dep1 [dep2...]])
|
|
|
|
function(generate_source)
|
|
|
|
set(options)
|
|
|
|
set(oneValueArgs OUTPUT)
|
|
|
|
set(multiValueArgs DEPENDS)
|
|
|
|
cmake_parse_arguments(_GSO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
|
|
if (NOT _GSO_OUTPUT)
|
|
|
|
message(FATAL_ERROR "Invalid arguments. generate_source requires output.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}"
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
"-DOUTPUT=${_GSO_OUTPUT}"
|
|
|
|
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake"
|
|
|
|
DEPENDS ${_GSO_DEPENDS}
|
|
|
|
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# Copy file
|
|
|
|
function(generate_copy source destination)
|
|
|
|
add_custom_command(OUTPUT "${destination}"
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E remove "${destination}"
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy "${source}"
|
|
|
|
"${destination}"
|
|
|
|
DEPENDS "${source}")
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# Generate scripts/pnglibconf.h
|
|
|
|
generate_source(OUTPUT "scripts/pnglibconf.c"
|
|
|
|
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h")
|
|
|
|
|
|
|
|
# Generate pnglibconf.c
|
|
|
|
generate_source(OUTPUT "pnglibconf.c"
|
|
|
|
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h")
|
|
|
|
|
|
|
|
if(PNG_PREFIX)
|
|
|
|
set(PNGLIBCONF_H_EXTRA_DEPENDS
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/macro.lst")
|
|
|
|
set(PNGPREFIX_H_EXTRA_DEPENDS
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
generate_out(INPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c"
|
|
|
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out")
|
|
|
|
|
|
|
|
# Generate pnglibconf.h
|
|
|
|
generate_source(OUTPUT "pnglibconf.h"
|
|
|
|
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out"
|
|
|
|
${PNGLIBCONF_H_EXTRA_DEPENDS})
|
|
|
|
|
|
|
|
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/intprefix.c"
|
|
|
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out"
|
|
|
|
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
|
|
|
|
|
|
|
|
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/prefix.c"
|
|
|
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
|
|
|
|
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out")
|
|
|
|
|
|
|
|
# Generate pngprefix.h
|
|
|
|
generate_source(OUTPUT "pngprefix.h"
|
|
|
|
DEPENDS ${PNGPREFIX_H_EXTRA_DEPENDS})
|
|
|
|
|
|
|
|
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/sym.c"
|
|
|
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
|
|
|
|
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
|
|
|
|
|
|
|
|
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.c"
|
|
|
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
|
|
|
|
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt")
|
|
|
|
|
|
|
|
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/vers.c"
|
|
|
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out"
|
|
|
|
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
|
|
|
|
|
|
|
|
generate_chk(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
|
|
|
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk"
|
|
|
|
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.def")
|
|
|
|
|
|
|
|
add_custom_target(symbol-check DEPENDS
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk")
|
|
|
|
|
|
|
|
generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/libpng.sym")
|
|
|
|
generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/libpng.vers")
|
|
|
|
|
|
|
|
add_custom_target(genvers DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers")
|
|
|
|
add_custom_target(gensym DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym")
|
|
|
|
|
|
|
|
add_custom_target("genprebuilt"
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
"-DOUTPUT=scripts/pnglibconf.h.prebuilt"
|
|
|
|
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake"
|
|
|
|
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
|
|
|
|
|
|
|
# A single target handles generation of all generated files. If
|
|
|
|
# they are dependend upon separately by multiple targets, this
|
|
|
|
# confuses parallel make (it would require a separate top-level
|
|
|
|
# target for each file to track the dependencies properly).
|
|
|
|
add_custom_target(genfiles DEPENDS
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/libpng.sym"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/libpng.vers"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out")
|
|
|
|
endif(NOT AWK)
|
|
|
|
|
2007-05-15 17:16:34 -04:00
|
|
|
# OUR SOURCES
|
2010-10-02 22:25:01 -04:00
|
|
|
set(libpng_public_hdrs
|
2010-02-07 19:08:50 -05:00
|
|
|
png.h
|
|
|
|
pngconf.h
|
2016-02-09 10:08:46 -05:00
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
|
2010-10-02 22:25:01 -04:00
|
|
|
)
|
2016-01-28 16:58:45 -05:00
|
|
|
set(libpng_private_hdrs
|
|
|
|
pngpriv.h
|
|
|
|
pngdebug.h
|
|
|
|
pnginfo.h
|
|
|
|
pngstruct.h
|
|
|
|
)
|
|
|
|
if(AWK)
|
|
|
|
list(APPEND libpng_private_hdrs "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h")
|
|
|
|
endif()
|
2010-10-02 22:25:01 -04:00
|
|
|
set(libpng_sources
|
|
|
|
${libpng_public_hdrs}
|
2016-01-28 16:58:45 -05:00
|
|
|
${libpng_private_hdrs}
|
2010-02-07 19:08:50 -05:00
|
|
|
png.c
|
|
|
|
pngerror.c
|
|
|
|
pngget.c
|
|
|
|
pngmem.c
|
|
|
|
pngpread.c
|
|
|
|
pngread.c
|
|
|
|
pngrio.c
|
|
|
|
pngrtran.c
|
|
|
|
pngrutil.c
|
|
|
|
pngset.c
|
|
|
|
pngtrans.c
|
|
|
|
pngwio.c
|
|
|
|
pngwrite.c
|
|
|
|
pngwtran.c
|
|
|
|
pngwutil.c
|
2006-12-07 20:16:44 -05:00
|
|
|
)
|
|
|
|
set(pngtest_sources
|
2010-02-07 19:08:50 -05:00
|
|
|
pngtest.c
|
2006-12-07 20:16:44 -05:00
|
|
|
)
|
2011-09-27 20:01:58 -04:00
|
|
|
set(pngvalid_sources
|
2011-12-08 10:53:00 -05:00
|
|
|
contrib/libtests/pngvalid.c
|
|
|
|
)
|
|
|
|
set(pngstest_sources
|
|
|
|
contrib/libtests/pngstest.c
|
2011-09-27 20:01:58 -04:00
|
|
|
)
|
2016-01-28 16:58:45 -05:00
|
|
|
set(pngunknown_sources
|
|
|
|
contrib/libtests/pngunknown.c
|
|
|
|
)
|
|
|
|
set(pngimage_sources
|
|
|
|
contrib/libtests/pngimage.c
|
|
|
|
)
|
|
|
|
set(pngfix_sources
|
|
|
|
contrib/tools/pngfix.c
|
|
|
|
)
|
|
|
|
set(png_fix_itxt_sources
|
|
|
|
contrib/tools/png-fix-itxt.c
|
|
|
|
)
|
2009-11-07 13:02:48 -05:00
|
|
|
|
2006-12-07 20:16:44 -05:00
|
|
|
if(MSVC)
|
2011-09-27 20:01:58 -04:00
|
|
|
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
2006-12-07 20:16:44 -05:00
|
|
|
endif(MSVC)
|
|
|
|
|
2007-05-15 17:16:34 -04:00
|
|
|
if(PNG_DEBUG)
|
2010-08-23 18:07:32 -04:00
|
|
|
add_definitions(-DPNG_DEBUG)
|
2009-08-27 16:59:40 -04:00
|
|
|
endif()
|
2007-05-15 17:16:34 -04:00
|
|
|
|
|
|
|
# NOW BUILD OUR TARGET
|
2010-02-07 19:08:50 -05:00
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR})
|
2006-12-07 20:16:44 -05:00
|
|
|
|
2013-03-07 12:17:17 -05:00
|
|
|
unset(PNG_LIB_TARGETS)
|
|
|
|
|
2006-12-07 20:16:44 -05:00
|
|
|
if(PNG_SHARED)
|
2016-01-28 16:58:45 -05:00
|
|
|
add_library(png SHARED ${libpng_sources})
|
|
|
|
set(PNG_LIB_TARGETS png)
|
|
|
|
set_target_properties(png PROPERTIES OUTPUT_NAME ${PNG_LIB_NAME})
|
|
|
|
add_dependencies(png genfiles)
|
2010-02-07 19:08:50 -05:00
|
|
|
if(MSVC)
|
|
|
|
# msvc does not append 'lib' - do it here to have consistent name
|
2016-01-28 16:58:45 -05:00
|
|
|
set_target_properties(png PROPERTIES PREFIX "lib")
|
|
|
|
set_target_properties(png PROPERTIES IMPORT_PREFIX "lib")
|
|
|
|
endif()
|
|
|
|
target_link_libraries(png ${ZLIB_LIBRARY} ${M_LIBRARY})
|
|
|
|
|
|
|
|
if(UNIX AND AWK)
|
|
|
|
if(HAVE_LD_VERSION_SCRIPT)
|
|
|
|
set_target_properties(png PROPERTIES LINK_FLAGS
|
|
|
|
"-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'")
|
|
|
|
elseif(HAVE_SOLARIS_LD_VERSION_SCRIPT)
|
|
|
|
set_target_properties(png PROPERTIES LINK_FLAGS
|
|
|
|
"-Wl,-M -Wl,'${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'")
|
|
|
|
endif()
|
2010-02-07 19:08:50 -05:00
|
|
|
endif()
|
2009-08-27 16:59:40 -04:00
|
|
|
endif()
|
|
|
|
|
2007-05-15 17:16:34 -04:00
|
|
|
if(PNG_STATIC)
|
2015-03-12 07:48:01 -04:00
|
|
|
# does not work without changing name
|
2016-01-28 16:58:45 -05:00
|
|
|
set(PNG_LIB_NAME_STATIC png_static)
|
|
|
|
add_library(png_static STATIC ${libpng_sources})
|
|
|
|
add_dependencies(png_static genfiles)
|
|
|
|
# MSVC doesn't use a different file extension for shared vs. static
|
|
|
|
# libs. We are able to change OUTPUT_NAME to remove the _static
|
|
|
|
# for all other platforms.
|
|
|
|
if(NOT MSVC)
|
|
|
|
set_target_properties(png_static PROPERTIES
|
|
|
|
OUTPUT_NAME "${PNG_LIB_NAME}"
|
|
|
|
CLEAN_DIRECT_OUTPUT 1)
|
|
|
|
else()
|
|
|
|
set_target_properties(png_static PROPERTIES
|
|
|
|
OUTPUT_NAME "${PNG_LIB_NAME}_static"
|
|
|
|
CLEAN_DIRECT_OUTPUT 1)
|
|
|
|
endif()
|
|
|
|
list(APPEND PNG_LIB_TARGETS png_static)
|
2010-02-07 19:08:50 -05:00
|
|
|
if(MSVC)
|
|
|
|
# msvc does not append 'lib' - do it here to have consistent name
|
2016-01-28 16:58:45 -05:00
|
|
|
set_target_properties(png_static PROPERTIES PREFIX "lib")
|
2010-02-07 19:08:50 -05:00
|
|
|
endif()
|
2016-01-28 16:58:45 -05:00
|
|
|
target_link_libraries(png_static ${ZLIB_LIBRARY} ${M_LIBRARY})
|
2009-08-27 16:59:40 -04:00
|
|
|
endif()
|
|
|
|
|
2015-03-12 07:48:01 -04:00
|
|
|
if(PNG_FRAMEWORK)
|
2016-01-28 16:58:45 -05:00
|
|
|
set(PNG_LIB_NAME_FRAMEWORK png_framework)
|
|
|
|
add_library(png_framework SHARED ${libpng_sources})
|
|
|
|
add_dependencies(png_framework genfiles)
|
|
|
|
list(APPEND PNG_LIB_TARGETS png_framework)
|
|
|
|
set_target_properties(png_framework PROPERTIES
|
2015-03-12 07:48:01 -04:00
|
|
|
FRAMEWORK TRUE
|
|
|
|
FRAMEWORK_VERSION ${PNGLIB_VERSION}
|
|
|
|
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PNGLIB_MAJOR}.${PNGLIB_MINOR}
|
|
|
|
MACOSX_FRAMEWORK_BUNDLE_VERSION ${PNGLIB_VERSION}
|
|
|
|
MACOSX_FRAMEWORK_IDENTIFIER org.libpng.libpng
|
|
|
|
XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
|
|
|
|
PUBLIC_HEADER "${libpng_public_hdrs}"
|
|
|
|
OUTPUT_NAME png)
|
2016-01-28 16:58:45 -05:00
|
|
|
target_link_libraries(png_framework ${ZLIB_LIBRARY} ${M_LIBRARY})
|
2015-03-12 07:48:01 -04:00
|
|
|
endif()
|
|
|
|
|
2013-03-07 12:17:17 -05:00
|
|
|
if(NOT PNG_LIB_TARGETS)
|
|
|
|
message(SEND_ERROR
|
|
|
|
"No library variant selected to build. "
|
2015-03-12 07:48:01 -04:00
|
|
|
"Please enable at least one of the following options: "
|
|
|
|
" PNG_STATIC, PNG_SHARED, PNG_FRAMEWORK")
|
2013-03-07 12:17:17 -05:00
|
|
|
endif()
|
|
|
|
|
2006-12-07 20:16:44 -05:00
|
|
|
if(PNG_SHARED AND WIN32)
|
2016-01-28 16:58:45 -05:00
|
|
|
set_target_properties(png PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
|
2009-08-27 16:59:40 -04:00
|
|
|
endif()
|
2006-12-07 20:16:44 -05:00
|
|
|
|
2016-01-28 16:58:45 -05:00
|
|
|
function(png_add_test)
|
|
|
|
set(options)
|
|
|
|
set(oneValueArgs NAME COMMAND)
|
|
|
|
set(multiValueArgs OPTIONS FILES)
|
|
|
|
cmake_parse_arguments(_PAT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
|
|
|
|
|
|
if (NOT _PAT_NAME)
|
|
|
|
message(FATAL_ERROR "Invalid arguments. png_add_test requires name.")
|
|
|
|
endif()
|
|
|
|
if (NOT _PAT_COMMAND)
|
|
|
|
message(FATAL_ERROR "Invalid arguments. png_add_test requires command.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(TEST_OPTIONS "${_PAT_OPTIONS}")
|
|
|
|
set(TEST_FILES "${_PAT_FILES}")
|
|
|
|
|
|
|
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/test.cmake.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake" @ONLY)
|
|
|
|
if(CMAKE_MAJOR_VERSION GREATER 2) # have generator expressions
|
|
|
|
add_test(NAME "${_PAT_NAME}"
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
"-DLIBPNG=$<TARGET_FILE:png>"
|
|
|
|
"-DTEST_COMMAND=$<TARGET_FILE:${_PAT_COMMAND}>"
|
|
|
|
-P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake")
|
|
|
|
else() # old 2.x add_test; limited and won't work well on Windows
|
|
|
|
# Note LIBPNG is a dummy value as there are no generator expressions
|
|
|
|
add_test("${_PAT_NAME}" "${CMAKE_COMMAND}"
|
|
|
|
"-DLIBPNG=${CMAKE_CURRENT_BINARY_DIR}/libpng.so"
|
|
|
|
"-DTEST_COMMAND=./${_PAT_COMMAND}"
|
|
|
|
-P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake")
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2009-08-27 16:59:40 -04:00
|
|
|
if(PNG_TESTS AND PNG_SHARED)
|
2016-01-29 09:25:14 -05:00
|
|
|
# Find test PNG files by globbing, but sort lists to ensure
|
|
|
|
# consistency between different filesystems.
|
2016-01-28 16:58:45 -05:00
|
|
|
file(GLOB PNGSUITE_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/*.png")
|
2016-01-29 09:25:14 -05:00
|
|
|
list(SORT PNGSUITE_PNGS)
|
2016-01-28 16:58:45 -05:00
|
|
|
file(GLOB TEST_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/testpngs/*.png")
|
2016-01-29 09:25:14 -05:00
|
|
|
list(SORT TEST_PNGS)
|
2016-01-28 16:58:45 -05:00
|
|
|
|
|
|
|
set(PNGTEST_PNG "${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png")
|
|
|
|
|
2010-02-07 19:08:50 -05:00
|
|
|
add_executable(pngtest ${pngtest_sources})
|
2016-01-28 16:58:45 -05:00
|
|
|
target_link_libraries(pngtest png)
|
|
|
|
|
|
|
|
png_add_test(NAME pngtest COMMAND pngtest FILES "${PNGTEST_PNG}")
|
|
|
|
|
2011-09-27 20:01:58 -04:00
|
|
|
add_executable(pngvalid ${pngvalid_sources})
|
2016-01-28 16:58:45 -05:00
|
|
|
target_link_libraries(pngvalid png)
|
|
|
|
|
|
|
|
png_add_test(NAME pngvalid-gamma-16-to-8
|
|
|
|
COMMAND pngvalid OPTIONS --gamma-16-to-8)
|
|
|
|
png_add_test(NAME pngvalid-gamma-alpha-mode
|
|
|
|
COMMAND pngvalid OPTIONS --gamma-alpha-mode)
|
|
|
|
png_add_test(NAME pngvalid-gamma-background
|
|
|
|
COMMAND pngvalid OPTIONS --gamma-background)
|
2016-02-08 18:04:04 -05:00
|
|
|
png_add_test(NAME pngvalid-gamma-expand16-alpha-mode
|
2016-01-28 16:58:45 -05:00
|
|
|
COMMAND pngvalid OPTIONS --gamma-alpha-mode --expand16)
|
2016-02-08 18:04:04 -05:00
|
|
|
png_add_test(NAME pngvalid-gamma-expand16-background
|
2016-01-28 16:58:45 -05:00
|
|
|
COMMAND pngvalid OPTIONS --gamma-background --expand16)
|
2016-02-08 18:04:04 -05:00
|
|
|
png_add_test(NAME pngvalid-gamma-expand16-transform
|
2016-01-28 16:58:45 -05:00
|
|
|
COMMAND pngvalid OPTIONS --gamma-transform --expand16)
|
|
|
|
png_add_test(NAME pngvalid-gamma-sbit
|
|
|
|
COMMAND pngvalid OPTIONS --gamma-sbit)
|
|
|
|
png_add_test(NAME pngvalid-gamma-threshold
|
|
|
|
COMMAND pngvalid OPTIONS --gamma-threshold)
|
|
|
|
png_add_test(NAME pngvalid-gamma-transform
|
|
|
|
COMMAND pngvalid OPTIONS --gamma-transform)
|
2016-02-08 18:04:04 -05:00
|
|
|
png_add_test(NAME pngvalid-progressive-interlace-standard
|
2016-01-28 16:58:45 -05:00
|
|
|
COMMAND pngvalid OPTIONS --standard --progressive-read --interlace)
|
2016-02-08 18:04:04 -05:00
|
|
|
png_add_test(NAME pngvalid-progressive-size
|
2016-01-28 16:58:45 -05:00
|
|
|
COMMAND pngvalid OPTIONS --size --progressive-read)
|
2016-02-08 18:04:04 -05:00
|
|
|
png_add_test(NAME pngvalid-progressive-standard
|
2016-01-28 16:58:45 -05:00
|
|
|
COMMAND pngvalid OPTIONS --standard --progressive-read)
|
|
|
|
png_add_test(NAME pngvalid-standard
|
|
|
|
COMMAND pngvalid OPTIONS --standard)
|
|
|
|
png_add_test(NAME pngvalid-transform
|
|
|
|
COMMAND pngvalid OPTIONS --transform)
|
|
|
|
|
2011-12-08 10:53:00 -05:00
|
|
|
add_executable(pngstest ${pngstest_sources})
|
2016-01-28 16:58:45 -05:00
|
|
|
target_link_libraries(pngstest png)
|
|
|
|
|
|
|
|
foreach(gamma_type 1.8 linear none sRGB)
|
|
|
|
foreach(alpha_type none alpha)
|
|
|
|
set(PNGSTEST_FILES)
|
|
|
|
foreach(test_png ${TEST_PNGS})
|
|
|
|
string(REGEX MATCH ".*-linear[-.].*" TEST_PNG_LINEAR "${test_png}")
|
|
|
|
string(REGEX MATCH ".*-sRGB[-.].*" TEST_PNG_SRGB "${test_png}")
|
|
|
|
string(REGEX MATCH ".*-1.8[-.].*" TEST_PNG_G18 "${test_png}")
|
|
|
|
string(REGEX MATCH ".*-alpha-.*" TEST_PNG_ALPHA "${test_png}")
|
|
|
|
|
|
|
|
set(TEST_PNG_VALID TRUE)
|
|
|
|
|
|
|
|
if(TEST_PNG_ALPHA)
|
|
|
|
if (NOT "${alpha_type}" STREQUAL "alpha")
|
|
|
|
set(TEST_PNG_VALID FALSE)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
if ("${alpha_type}" STREQUAL "alpha")
|
|
|
|
set(TEST_PNG_VALID FALSE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(TEST_PNG_LINEAR)
|
|
|
|
if(NOT "${gamma_type}" STREQUAL "linear")
|
|
|
|
set(TEST_PNG_VALID FALSE)
|
|
|
|
endif()
|
|
|
|
elseif(TEST_PNG_SRGB)
|
|
|
|
if(NOT "${gamma_type}" STREQUAL "sRGB")
|
|
|
|
set(TEST_PNG_VALID FALSE)
|
|
|
|
endif()
|
|
|
|
elseif(TEST_PNG_G18)
|
|
|
|
if(NOT "${gamma_type}" STREQUAL "1.8")
|
|
|
|
set(TEST_PNG_VALID FALSE)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
if(NOT "${gamma_type}" STREQUAL "none")
|
|
|
|
set(TEST_PNG_VALID FALSE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(TEST_PNG_VALID)
|
|
|
|
list(APPEND PNGSTEST_FILES "${test_png}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2016-01-29 09:25:14 -05:00
|
|
|
# Should already be sorted, but sort anyway to be certain.
|
|
|
|
list(SORT PNGSTEST_FILES)
|
2016-01-28 16:58:45 -05:00
|
|
|
png_add_test(NAME pngstest-${gamma_type}-${alpha_type}
|
|
|
|
COMMAND pngstest
|
|
|
|
OPTIONS --tmpfile "${gamma_type}-${alpha_type}-" --log
|
|
|
|
FILES ${PNGSTEST_FILES})
|
|
|
|
endforeach()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
add_executable(pngunknown ${pngunknown_sources})
|
|
|
|
target_link_libraries(pngunknown png)
|
|
|
|
|
|
|
|
png_add_test(NAME pngunknown-discard COMMAND pngunknown OPTIONS --strict default=discard FILES "${PNGTEST_PNG}")
|
|
|
|
png_add_test(NAME pngunknown-IDAT COMMAND pngunknown OPTIONS --strict default=discard IDAT=save FILES "${PNGTEST_PNG}")
|
|
|
|
png_add_test(NAME pngunknown-if-safe COMMAND pngunknown OPTIONS --strict default=if-safe FILES "${PNGTEST_PNG}")
|
|
|
|
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}")
|
|
|
|
png_add_test(NAME pngunknown-save COMMAND pngunknown OPTIONS --strict default=save FILES "${PNGTEST_PNG}")
|
|
|
|
png_add_test(NAME pngunknown-sTER COMMAND pngunknown OPTIONS --strict sTER=if-safe FILES "${PNGTEST_PNG}")
|
|
|
|
png_add_test(NAME pngunknown-vpAg COMMAND pngunknown OPTIONS --strict vpAg=if-safe FILES "${PNGTEST_PNG}")
|
|
|
|
|
|
|
|
add_executable(pngimage ${pngimage_sources})
|
|
|
|
target_link_libraries(pngimage png)
|
|
|
|
|
|
|
|
png_add_test(NAME pngimage-quick COMMAND pngimage OPTIONS --list-combos --log FILES ${PNGSUITE_PNGS})
|
|
|
|
png_add_test(NAME pngimage-full COMMAND pngimage OPTIONS --exhaustive --list-combos --log FILES ${PNGSUITE_PNGS})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(PNG_SHARED)
|
|
|
|
add_executable(pngfix ${pngfix_sources})
|
|
|
|
target_link_libraries(pngfix png)
|
|
|
|
set(PNG_BIN_TARGETS pngfix)
|
|
|
|
|
|
|
|
add_executable(png-fix-itxt ${png_fix_itxt_sources})
|
|
|
|
target_link_libraries(png-fix-itxt ${ZLIB_LIBRARY} ${M_LIBRARY})
|
|
|
|
list(APPEND PNG_BIN_TARGETS png-fix-itxt)
|
2009-08-27 16:59:40 -04:00
|
|
|
endif()
|
2006-12-07 20:16:44 -05:00
|
|
|
|
2011-08-17 10:02:07 -04:00
|
|
|
# Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set
|
|
|
|
IF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
2013-03-02 15:58:22 -05:00
|
|
|
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "lib")
|
2011-08-17 10:02:07 -04:00
|
|
|
ENDIF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
|
|
|
|
2010-10-02 22:25:01 -04:00
|
|
|
# Set a variable with CMake code which:
|
|
|
|
# Creates a symlink from src to dest (if possible) or alternatively
|
|
|
|
# copies if different.
|
2011-07-27 21:47:13 -04:00
|
|
|
macro(CREATE_SYMLINK SRC_FILE DEST_FILE)
|
2011-08-17 10:46:29 -04:00
|
|
|
FILE(REMOVE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
|
2013-03-02 15:58:22 -05:00
|
|
|
if(WIN32 AND NOT CYGWIN AND NOT MSYS)
|
2011-08-17 10:46:29 -04:00
|
|
|
ADD_CUSTOM_COMMAND(
|
|
|
|
OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
|
2013-03-07 12:17:17 -05:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_FILE}" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_FILE}" ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
|
|
|
|
DEPENDS ${PNG_LIB_TARGETS}
|
2011-08-17 10:46:29 -04:00
|
|
|
)
|
|
|
|
ADD_CUSTOM_TARGET(${DEST_FILE}_COPY ALL DEPENDS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
|
2013-03-02 15:58:22 -05:00
|
|
|
else(WIN32 AND NOT CYGWIN AND NOT MSYS)
|
2013-03-07 12:17:17 -05:00
|
|
|
get_filename_component(LINK_TARGET "${SRC_FILE}" NAME)
|
2014-07-30 09:09:22 -04:00
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
2013-03-07 12:17:17 -05:00
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${LINK_TARGET}" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${LINK_TARGET}" ${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
2013-03-02 15:58:22 -05:00
|
|
|
endif(WIN32 AND NOT CYGWIN AND NOT MSYS)
|
2010-10-02 22:25:01 -04:00
|
|
|
endmacro()
|
2006-12-07 20:16:44 -05:00
|
|
|
|
2016-01-28 16:58:45 -05:00
|
|
|
# Create source generation scripts.
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genchk.cmake.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake @ONLY)
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genout.cmake.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake @ONLY)
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/gensrc.cmake.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake @ONLY)
|
|
|
|
|
|
|
|
|
2011-09-27 20:01:58 -04:00
|
|
|
# libpng is a library so default to 'lib'
|
2010-08-23 18:07:32 -04:00
|
|
|
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
2011-01-14 18:08:28 -05:00
|
|
|
set(CMAKE_INSTALL_LIBDIR lib)
|
2010-08-23 18:07:32 -04:00
|
|
|
endif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
2011-09-27 20:01:58 -04:00
|
|
|
|
|
|
|
# CREATE PKGCONFIG FILES
|
|
|
|
# we use the same files like ./configure, so we have to set its vars
|
|
|
|
# Only do this on Windows for Cygwin - the files don't make much sense outside
|
|
|
|
# a UNIX look alike
|
2013-03-02 15:58:22 -05:00
|
|
|
if(NOT WIN32 OR CYGWIN OR MINGW)
|
|
|
|
set(prefix ${CMAKE_INSTALL_PREFIX})
|
|
|
|
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
|
|
|
|
set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
|
|
|
|
set(includedir ${CMAKE_INSTALL_PREFIX}/include)
|
|
|
|
set(LIBS "-lz -lm")
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY)
|
|
|
|
CREATE_SYMLINK(${PNGLIB_NAME}.pc libpng.pc)
|
|
|
|
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY)
|
|
|
|
CREATE_SYMLINK(${PNGLIB_NAME}-config libpng-config)
|
2011-11-21 13:37:13 -05:00
|
|
|
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
2007-05-15 17:16:34 -04:00
|
|
|
|
|
|
|
# SET UP LINKS
|
2009-08-27 16:59:40 -04:00
|
|
|
if(PNG_SHARED)
|
2016-01-28 16:58:45 -05:00
|
|
|
set_target_properties(png PROPERTIES
|
2016-04-27 13:24:02 -04:00
|
|
|
# VERSION 16.${PNGLIB_RELEASE}.1.6.22beta06
|
2011-11-24 15:40:36 -05:00
|
|
|
VERSION 16.${PNGLIB_RELEASE}.0
|
|
|
|
SOVERSION 16
|
2010-02-07 19:08:50 -05:00
|
|
|
CLEAN_DIRECT_OUTPUT 1)
|
2009-08-27 16:59:40 -04:00
|
|
|
endif()
|
|
|
|
|
2010-10-02 22:25:01 -04:00
|
|
|
# If CMake > 2.4.x, we set a variable used below to export
|
|
|
|
# targets to an export file.
|
|
|
|
# TODO: Use VERSION_GREATER after our cmake_minimum_required >= 2.6.2
|
|
|
|
if(CMAKE_MAJOR_VERSION GREATER 1 AND CMAKE_MINOR_VERSION GREATER 4)
|
|
|
|
set(PNG_EXPORT_RULE EXPORT libpng)
|
|
|
|
elseif(CMAKE_MAJOR_VERSION GREATER 2) # future proof
|
|
|
|
set(PNG_EXPORT_RULE EXPORT libpng)
|
|
|
|
endif()
|
|
|
|
|
2009-08-27 16:59:40 -04:00
|
|
|
# INSTALL
|
|
|
|
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
|
2013-03-07 12:17:17 -05:00
|
|
|
install(TARGETS ${PNG_LIB_TARGETS}
|
|
|
|
${PNG_EXPORT_RULE}
|
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
2015-03-12 07:48:01 -04:00
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
2010-10-02 22:25:01 -04:00
|
|
|
|
2013-03-07 12:17:17 -05:00
|
|
|
if(PNG_SHARED)
|
2011-11-24 15:40:36 -05:00
|
|
|
# Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin
|
2011-11-21 13:37:13 -05:00
|
|
|
if(CYGWIN OR MINGW)
|
2016-01-28 16:58:45 -05:00
|
|
|
get_target_property(BUILD_TARGET_LOCATION png LOCATION_${CMAKE_BUILD_TYPE})
|
2013-03-07 12:17:17 -05:00
|
|
|
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
|
2011-08-17 10:46:29 -04:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
2011-11-21 13:37:13 -05:00
|
|
|
endif(CYGWIN OR MINGW)
|
2010-10-02 22:25:01 -04:00
|
|
|
|
|
|
|
if(NOT WIN32)
|
2016-01-28 16:58:45 -05:00
|
|
|
get_target_property(BUILD_TARGET_LOCATION png LOCATION_${CMAKE_BUILD_TYPE})
|
2013-03-07 12:17:17 -05:00
|
|
|
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
|
2011-08-17 10:46:29 -04:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
2011-07-27 21:47:13 -04:00
|
|
|
endif(NOT WIN32)
|
|
|
|
endif(PNG_SHARED)
|
2010-10-02 22:25:01 -04:00
|
|
|
|
2010-02-07 19:08:50 -05:00
|
|
|
if(PNG_STATIC)
|
2011-11-21 13:37:13 -05:00
|
|
|
if(NOT WIN32 OR CYGWIN OR MINGW)
|
2016-01-28 16:58:45 -05:00
|
|
|
get_target_property(BUILD_TARGET_LOCATION png_static LOCATION_${CMAKE_BUILD_TYPE})
|
2013-03-07 12:17:17 -05:00
|
|
|
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
|
2011-08-17 10:46:29 -04:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
2011-11-21 13:37:13 -05:00
|
|
|
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
2011-07-27 21:47:13 -04:00
|
|
|
endif()
|
2009-08-27 16:59:40 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
|
2010-10-02 22:25:01 -04:00
|
|
|
install(FILES ${libpng_public_hdrs} DESTINATION include)
|
|
|
|
install(FILES ${libpng_public_hdrs} DESTINATION include/${PNGLIB_NAME})
|
2009-10-30 16:42:54 -04:00
|
|
|
endif()
|
|
|
|
if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL )
|
2013-03-02 15:58:22 -05:00
|
|
|
if(NOT WIN32 OR CYGWIN OR MINGW)
|
|
|
|
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION bin)
|
|
|
|
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
|
|
|
|
DESTINATION bin)
|
|
|
|
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
2009-08-27 16:59:40 -04:00
|
|
|
endif()
|
2013-03-02 15:58:22 -05:00
|
|
|
|
2016-01-28 16:58:45 -05:00
|
|
|
if(NOT SKIP_INSTALL_PROGRAMS AND NOT SKIP_INSTALL_ALL )
|
|
|
|
install(TARGETS ${PNG_BIN_TARGETS}
|
|
|
|
RUNTIME DESTINATION bin)
|
|
|
|
endif()
|
|
|
|
|
2009-08-27 16:59:40 -04:00
|
|
|
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
|
2010-02-07 19:08:50 -05:00
|
|
|
# Install man pages
|
2010-10-02 22:25:01 -04:00
|
|
|
if(NOT PNG_MAN_DIR)
|
|
|
|
set(PNG_MAN_DIR "share/man")
|
|
|
|
endif()
|
|
|
|
install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3)
|
|
|
|
install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5)
|
2010-02-07 19:08:50 -05:00
|
|
|
# Install pkg-config files
|
2013-03-02 15:58:22 -05:00
|
|
|
if(NOT WIN32 OR CYGWIN OR MINGW)
|
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
|
|
|
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config
|
|
|
|
DESTINATION bin)
|
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
|
|
|
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
|
|
|
|
DESTINATION bin)
|
|
|
|
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
2009-08-27 16:59:40 -04:00
|
|
|
endif()
|
2007-05-15 17:16:34 -04:00
|
|
|
|
2010-10-02 22:25:01 -04:00
|
|
|
# On versions of CMake that support it, create an export file CMake
|
|
|
|
# users can include() to import our targets
|
|
|
|
if(PNG_EXPORT_RULE AND NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL )
|
|
|
|
install(EXPORT libpng DESTINATION lib/libpng FILE lib${PNG_LIB_NAME}.cmake)
|
|
|
|
endif()
|
|
|
|
|
2014-07-30 09:09:22 -04:00
|
|
|
# what's with libpng-manual.txt and all the extra files?
|
2006-12-07 20:16:44 -05:00
|
|
|
|
2007-05-15 17:16:34 -04:00
|
|
|
# UNINSTALL
|
2006-12-07 20:16:44 -05:00
|
|
|
# do we need this?
|
|
|
|
|
2007-05-15 17:16:34 -04:00
|
|
|
# DIST
|
2006-12-07 20:16:44 -05:00
|
|
|
# do we need this?
|
|
|
|
|
|
|
|
# to create msvc import lib for mingw compiled shared lib
|
|
|
|
# pexports libpng.dll > libpng.def
|
|
|
|
# lib /def:libpng.def /machine:x86
|
2009-05-02 16:36:08 -04:00
|
|
|
|