aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt241
1 files changed, 191 insertions, 50 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index eb63b2bfe..48c6fa287 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,17 +1,18 @@
# CMakeLists.txt
-# Copyright (C) 2007,2009-2016 Glenn Randers-Pehrson
+# Copyright (C) 2007,2009-2017 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
+# Revised by Andreas Franek, 2016
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
# and license in png.h
-cmake_minimum_required(VERSION 2.8.3)
-cmake_policy(VERSION 2.8.3)
+cmake_minimum_required(VERSION 3.0.2)
+cmake_policy(VERSION 3.0.2)
# Set MacOSX @rpath usage globally.
if (POLICY CMP0020)
@@ -30,18 +31,27 @@ endif(POLICY CMP0054)
set(CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo")
-project(libpng C)
+project(libpng ASM C)
enable_testing()
set(PNGLIB_MAJOR 1)
set(PNGLIB_MINOR 6)
-set(PNGLIB_RELEASE 25)
+set(PNGLIB_RELEASE 34)
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
+include(GNUInstallDirs)
+
# needed packages
-find_package(ZLIB REQUIRED)
-include_directories(${ZLIB_INCLUDE_DIR})
+
+#Allow users to specify location of Zlib,
+# Useful if zlib is being built alongside this as a sub-project
+option(PNG_BUILD_ZLIB "Custom zlib Location, else find_package is used" OFF)
+
+IF(NOT PNG_BUILD_ZLIB)
+ find_package(ZLIB REQUIRED)
+ include_directories(${ZLIB_INCLUDE_DIR})
+ENDIF(NOT PNG_BUILD_ZLIB)
if(NOT WIN32)
find_library(M_LIBRARY
@@ -66,9 +76,116 @@ option(PNG_FRAMEWORK "Build OS X framework" OFF)
option(PNG_DEBUG "Build with debug output" OFF)
option(PNGARG "Disable ANSI-C prototypes" OFF)
+option(PNG_HARDWARE_OPTIMIZATIONS "Enable Hardware Optimizations" ON)
+
+
set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names")
set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings")
+if(PNG_HARDWARE_OPTIMIZATIONS)
+# set definitions and sources for arm
+if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR
+ CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
+ set(PNG_ARM_NEON_POSSIBLE_VALUES check on off)
+ set(PNG_ARM_NEON "check" CACHE STRING "Enable ARM NEON optimizations:
+ check: (default) use internal checking code;
+ off: disable the optimizations;
+ on: turn on unconditionally.")
+ set_property(CACHE PNG_ARM_NEON PROPERTY STRINGS
+ ${PNG_ARM_NEON_POSSIBLE_VALUES})
+ list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index)
+ if(index EQUAL -1)
+ message(FATAL_ERROR
+ " PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]")
+ elseif(NOT ${PNG_ARM_NEON} STREQUAL "no")
+ set(libpng_arm_sources
+ arm/arm_init.c
+ arm/filter_neon.S
+ arm/filter_neon_intrinsics.c)
+
+ if(${PNG_ARM_NEON} STREQUAL "on")
+ add_definitions(-DPNG_ARM_NEON_OPT=2)
+ elseif(${PNG_ARM_NEON} STREQUAL "check")
+ add_definitions(-DPNG_ARM_NEON_CHECK_SUPPORTED)
+ endif()
+ else()
+ add_definitions(-DPNG_ARM_NEON_OPT=0)
+ endif()
+endif()
+
+# set definitions and sources for powerpc
+if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR
+ CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*" )
+ set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off)
+ set(PNG_POWERPC_VSX "on" CACHE STRING "Enable POWERPC VSX optimizations:
+ off: disable the optimizations.")
+ set_property(CACHE PNG_POWERPC_VSX PROPERTY STRINGS
+ ${PNG_POWERPC_VSX_POSSIBLE_VALUES})
+ list(FIND PNG_POWERPC_VSX_POSSIBLE_VALUES ${PNG_POWERPC_VSX} index)
+ if(index EQUAL -1)
+ message(FATAL_ERROR
+ " PNG_POWERPC_VSX must be one of [${PNG_POWERPC_VSX_POSSIBLE_VALUES}]")
+ elseif(NOT ${PNG_POWERPC_VSX} STREQUAL "no")
+ set(libpng_powerpc_sources
+ powerpc/powerpc_init.c
+ powerpc/filter_vsx_intrinsics.c)
+ if(${PNG_POWERPC_VSX} STREQUAL "on")
+ add_definitions(-DPNG_POWERPC_VSX_OPT=2)
+ endif()
+ else()
+ add_definitions(-DPNG_POWERPC_VSX_OPT=0)
+ endif()
+endif()
+
+# set definitions and sources for intel
+if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR
+ CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*" )
+ set(PNG_INTEL_SSE_POSSIBLE_VALUES on off)
+ set(PNG_INTEL_SSE "on" CACHE STRING "Enable INTEL_SSE optimizations:
+ off: disable the optimizations")
+ set_property(CACHE PNG_INTEL_SSE PROPERTY STRINGS
+ ${PNG_INTEL_SSE_POSSIBLE_VALUES})
+ list(FIND PNG_INTEL_SSE_POSSIBLE_VALUES ${PNG_INTEL_SSE} index)
+ if(index EQUAL -1)
+ message(FATAL_ERROR
+ " PNG_INTEL_SSE must be one of [${PNG_INTEL_SSE_POSSIBLE_VALUES}]")
+ elseif(NOT ${PNG_INTEL_SSE} STREQUAL "no")
+ set(libpng_intel_sources
+ intel/intel_init.c
+ intel/filter_sse2_intrinsics.c)
+ if(${PNG_INTEL_SSE} STREQUAL "on")
+ add_definitions(-DPNG_INTEL_SSE_OPT=1)
+ endif()
+ else()
+ add_definitions(-DPNG_INTEL_SSE_OPT=0)
+ endif()
+endif()
+
+# set definitions and sources for MIPS
+if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR
+ CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*" )
+ set(PNG_MIPS_MSA_POSSIBLE_VALUES on off)
+ set(PNG_MIPS_MSA "on" CACHE STRING "Enable MIPS_MSA optimizations:
+ off: disable the optimizations")
+ set_property(CACHE PNG_MIPS_MSA PROPERTY STRINGS
+ ${PNG_MIPS_MSA_POSSIBLE_VALUES})
+ list(FIND PNG_MIPS_MSA_POSSIBLE_VALUES ${PNG_MIPS_MSA} index)
+ if(index EQUAL -1)
+ message(FATAL_ERROR
+ " PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]")
+ elseif(NOT ${PNG_MIPS_MSA} STREQUAL "no")
+ set(libpng_mips_sources
+ mips/mips_init.c
+ mips/filter_msa_intrinsics.c)
+ if(${PNG_MIPS_MSA} STREQUAL "on")
+ add_definitions(-DPNG_MIPS_MSA_OPT=2)
+ endif()
+ else()
+ add_definitions(-DPNG_MIPS_MSA_OPT=0)
+ endif()
+endif()
+endif(PNG_HARDWARE_OPTIMIZATIONS)
+
# SET LIBNAME
set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
@@ -145,7 +262,7 @@ find_program(AWK NAMES gawk awk)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
-if(NOT AWK)
+if(NOT AWK OR ANDROID)
# 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)
@@ -324,7 +441,7 @@ else()
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out")
-endif(NOT AWK)
+endif(NOT AWK OR ANDROID)
# OUR SOURCES
set(libpng_public_hdrs
@@ -338,7 +455,7 @@ set(libpng_private_hdrs
pnginfo.h
pngstruct.h
)
-if(AWK)
+if(AWK AND NOT ANDROID)
list(APPEND libpng_private_hdrs "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h")
endif()
set(libpng_sources
@@ -359,6 +476,10 @@ set(libpng_sources
pngwrite.c
pngwtran.c
pngwutil.c
+ ${libpng_arm_sources}
+ ${libpng_intel_sources}
+ ${libpng_mips_sources}
+ ${libpng_powerpc_sources}
)
set(pngtest_sources
pngtest.c
@@ -634,31 +755,58 @@ if(PNG_SHARED)
list(APPEND PNG_BIN_TARGETS png-fix-itxt)
endif()
-# Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set
-IF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
- SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "lib")
-ENDIF(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
-
# Set a variable with CMake code which:
# Creates a symlink from src to dest (if possible) or alternatively
# copies if different.
-macro(CREATE_SYMLINK SRC_FILE DEST_FILE)
- FILE(REMOVE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
- if(WIN32 AND NOT CYGWIN AND NOT MSYS)
- ADD_CUSTOM_COMMAND(
- OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
- 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}
- )
- ADD_CUSTOM_TARGET(${DEST_FILE}_COPY ALL DEPENDS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
- else(WIN32 AND NOT CYGWIN AND NOT MSYS)
- get_filename_component(LINK_TARGET "${SRC_FILE}" NAME)
- execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
- 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})
- endif(WIN32 AND NOT CYGWIN AND NOT MSYS)
-endmacro()
+include(CMakeParseArguments)
+
+function(CREATE_SYMLINK DEST_FILE)
+
+ cmake_parse_arguments(S "" "FILE;TARGET" "" ${ARGN})
+
+ if(NOT S_TARGET AND NOT S_FILE)
+ message(FATAL_ERROR "Specify either a TARGET or a FILE for CREATE_SYMLINK to link to.")
+ endif(NOT S_TARGET AND NOT S_FILE)
+
+ if(S_TARGET AND S_FILE)
+ 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.")
+ endif(S_TARGET AND S_FILE)
+
+ if(S_FILE)
+ # If we don't need to symlink something that's coming from a build target,
+ # we can go ahead and symlink/copy at configure time.
+
+ if(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
+ execute_process(
+ COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${S_FILE} ${DEST_FILE}
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+ )
+ else(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E create_symlink ${S_FILE} ${DEST_FILE}
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+ )
+ endif(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
+ endif(S_FILE)
+
+ if(S_TARGET)
+ # We need to use generator expressions, which can be a bit tricky, so for
+ # simplicity make the symlink a POST_BUILD step and use the TARGET
+ # signature of add_custom_command.
+
+ if(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
+ add_custom_command(TARGET ${S_TARGET} POST_BUILD
+ COMMAND "${CMAKE_COMMAND}" -E copy_if_different $<TARGET_LINKER_FILE_NAME:${S_TARGET}> $<TARGET_LINKER_FILE_DIR:${S_TARGET}>/${DEST_FILE}
+ )
+ else(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
+ add_custom_command(TARGET ${S_TARGET} POST_BUILD
+ COMMAND "${CMAKE_COMMAND}" -E create_symlink $<TARGET_LINKER_FILE_NAME:${S_TARGET}> $<TARGET_LINKER_FILE_DIR:${S_TARGET}>/${DEST_FILE}
+ )
+ endif(CMAKE_HOST_WIN32 AND NOT CYGWIN AND NOT MSYS)
+
+ endif(S_TARGET)
+
+endfunction()
# Create source generation scripts.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genchk.cmake.in
@@ -686,17 +834,17 @@ if(NOT WIN32 OR CYGWIN OR MINGW)
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)
+ CREATE_SYMLINK(libpng.pc FILE ${PNGLIB_NAME}.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)
+ CREATE_SYMLINK(libpng-config FILE ${PNGLIB_NAME}-config)
endif(NOT WIN32 OR CYGWIN OR MINGW)
# SET UP LINKS
if(PNG_SHARED)
set_target_properties(png PROPERTIES
-# VERSION 16.${PNGLIB_RELEASE}.1.6.25
+# VERSION 16.${PNGLIB_RELEASE}.1.6.34
VERSION 16.${PNGLIB_RELEASE}.0
SOVERSION 16
CLEAN_DIRECT_OUTPUT 1)
@@ -723,26 +871,20 @@ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
if(PNG_SHARED)
# Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin
if(CYGWIN OR MINGW)
- get_target_property(BUILD_TARGET_LOCATION png LOCATION_${CMAKE_BUILD_TYPE})
- CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}
- DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ CREATE_SYMLINK(libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} TARGET png)
+ install(FILES $<TARGET_LINKER_FILE_DIR:png>/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif(CYGWIN OR MINGW)
if(NOT WIN32)
- get_target_property(BUILD_TARGET_LOCATION png LOCATION_${CMAKE_BUILD_TYPE})
- CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
- DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ CREATE_SYMLINK(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png)
+ install(FILES $<TARGET_LINKER_FILE_DIR:png>/libpng${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif(NOT WIN32)
endif(PNG_SHARED)
if(PNG_STATIC)
if(NOT WIN32 OR CYGWIN OR MINGW)
- get_target_property(BUILD_TARGET_LOCATION png_static LOCATION_${CMAKE_BUILD_TYPE})
- CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
- DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ CREATE_SYMLINK( libpng${CMAKE_STATIC_LIBRARY_SUFFIX} TARGET png_static)
+ install(FILES $<TARGET_LINKER_FILE_DIR:png_static>/libpng${CMAKE_STATIC_LIBRARY_SUFFIX} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif(NOT WIN32 OR CYGWIN OR MINGW)
endif()
endif()
@@ -772,7 +914,7 @@ if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3)
install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5)
# Install pkg-config files
- if(NOT WIN32 OR CYGWIN OR MINGW)
+ if(NOT CMAKE_HOST_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
@@ -781,7 +923,7 @@ if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
DESTINATION bin)
- endif(NOT WIN32 OR CYGWIN OR MINGW)
+ endif(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW)
endif()
# On versions of CMake that support it, create an export file CMake
@@ -801,4 +943,3 @@ endif()
# to create msvc import lib for mingw compiled shared lib
# pexports libpng.dll > libpng.def
# lib /def:libpng.def /machine:x86
-