This repository has been archived on 2023-11-11. You can view files and clone it, but cannot push or open issues or pull requests.
libpng/CMakeLists.txt

113 lines
2.6 KiB
CMake

cmake_minimum_required(VERSION 3.1)
cmake_policy(VERSION 3.1)
project(libpng C)
# Copyright (C) 2007-2010 Glenn Randers-Pehrson
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
# and license in png.h
set(PNGLIB_MAJOR 1)
set(PNGLIB_MINOR 2)
set(PNGLIB_RELEASE 59)
set(PNGLIB_NAME "libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}")
set(PNGLIB_VERSION "${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE}")
# 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)
endif()
find_library(M_LIBRARY m)
if(NOT M_LIBRARY)
message(STATUS
"math library 'libm' not found - floating point support disabled")
endif()
option(PNG_NO_CONSOLE_IO "FIXME" YES)
option(PNG_NO_STDIO "FIXME" YES)
option(PNG_DEBUG "Build with debug output" NO)
option(PNGARG "FIXME" YES)
#TODO:
# PNG_CONSOLE_IO_SUPPORTED
# maybe needs improving, but currently I don't know when we can enable what :)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^.*i[1-9]86.*$")
set(png_asm_tmp ON)
else()
set(png_asm_tmp OFF)
endif()
# SET LIBNAME
set(PNG_LIB_NAME "png${PNGLIB_MAJOR}${PNGLIB_MINOR}")
# OUR SOURCES
set(libpng_sources
png.h
pngconf.h
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
)
# SOME NEEDED DEFINITIONS
add_definitions(-DPNG_CONFIGURE_LIBPNG)
add_definitions(-DZLIB_DLL)
add_definitions(-DLIBPNG_NO_MMX)
add_definitions(-DPNG_NO_MMX_CODE)
if(PNG_CONSOLE_IO_SUPPORTED)
add_definitions(-DPNG_CONSOLE_IO_SUPPORTED)
endif()
if(PNG_NO_CONSOLE_IO)
add_definitions(-DPNG_NO_CONSOLE_IO)
endif()
if(PNG_NO_STDIO)
add_definitions(-DPNG_NO_STDIO)
endif()
if(PNG_DEBUG)
add_definitions(-DPNG_DEBUG)
endif()
if(NOT M_LIBRARY)
add_definitions(-DPNG_NO_FLOATING_POINT_SUPPORTED)
endif()
# NOW BUILD OUR TARGET
add_library("${PNG_LIB_NAME}" SHARED ${libpng_sources})
target_link_libraries("${PNG_LIB_NAME}" "${ZLIB_LIBRARY}" "${M_LIBRARY}")
target_include_directories("${PNG_LIB_NAME}" PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>")
foreach(zlib_include_dir IN LISTS ZLIB_INCLUDE_DIRS)
target_include_directories("${PNG_LIB_NAME}" PUBLIC "$<BUILD_INTERFACE:${zlib_include_dir}>")
endforeach()
# SET UP LINKS
set_target_properties("${PNG_LIB_NAME}" PROPERTIES
# VERSION 0.${PNGLIB_RELEASE}.1.2.59
VERSION "0.${PNGLIB_RELEASE}.0"
SOVERSION 0
CLEAN_DIRECT_OUTPUT 1)