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
Raw Normal View History

2022-08-06 02:04:21 +00:00
cmake_minimum_required(VERSION 3.1)
cmake_policy(VERSION 3.1)
project(libpng C)
2006-12-07 04:06:25 +00:00
# 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
2007-01-05 12:59:12 +00:00
2006-12-14 02:54:57 +00:00
set(PNGLIB_MAJOR 1)
set(PNGLIB_MINOR 2)
set(PNGLIB_RELEASE 59)
2022-08-06 02:04:21 +00:00
set(PNGLIB_NAME "libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}")
set(PNGLIB_VERSION "${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE}")
2006-12-07 04:06:25 +00:00
2022-08-06 02:04:21 +00:00
# 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)
2022-08-06 02:04:21 +00:00
if(NOT PNG_BUILD_ZLIB)
find_package(ZLIB REQUIRED)
endif()
2006-12-07 04:06:25 +00:00
2022-08-06 02:04:21 +00:00
find_library(M_LIBRARY m)
if(NOT M_LIBRARY)
message(STATUS
"math library 'libm' not found - floating point support disabled")
endif()
2006-12-14 02:54:57 +00:00
option(PNG_NO_CONSOLE_IO "FIXME" YES)
option(PNG_NO_STDIO "FIXME" YES)
option(PNG_DEBUG "Build with debug output" NO)
2006-12-14 02:54:57 +00:00
option(PNGARG "FIXME" YES)
2006-12-07 04:06:25 +00:00
#TODO:
# PNG_CONSOLE_IO_SUPPORTED
2006-12-14 02:54:57 +00:00
# maybe needs improving, but currently I don't know when we can enable what :)
2022-08-06 02:04:21 +00:00
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^.*i[1-9]86.*$")
set(png_asm_tmp ON)
else()
2022-08-06 02:04:21 +00:00
set(png_asm_tmp OFF)
endif()
2006-12-08 01:21:29 +00:00
2006-12-14 02:54:57 +00:00
# SET LIBNAME
2022-08-06 02:04:21 +00:00
set(PNG_LIB_NAME "png${PNGLIB_MAJOR}${PNGLIB_MINOR}")
2006-12-07 04:06:25 +00:00
2006-12-14 02:54:57 +00:00
# OUR SOURCES
2006-12-07 04:06:25 +00:00
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
2006-12-07 04:06:25 +00:00
)
2006-12-14 02:54:57 +00:00
# SOME NEEDED DEFINITIONS
add_definitions(-DPNG_CONFIGURE_LIBPNG)
2022-08-06 02:04:21 +00:00
add_definitions(-DZLIB_DLL)
2007-09-01 20:12:50 +00:00
add_definitions(-DLIBPNG_NO_MMX)
add_definitions(-DPNG_NO_MMX_CODE)
2006-12-07 04:06:25 +00:00
2006-12-14 02:54:57 +00:00
if(PNG_CONSOLE_IO_SUPPORTED)
add_definitions(-DPNG_CONSOLE_IO_SUPPORTED)
endif()
2006-12-14 02:54:57 +00:00
if(PNG_NO_CONSOLE_IO)
add_definitions(-DPNG_NO_CONSOLE_IO)
endif()
2006-12-14 02:54:57 +00:00
if(PNG_NO_STDIO)
add_definitions(-DPNG_NO_STDIO)
endif()
2006-12-14 02:54:57 +00:00
if(PNG_DEBUG)
add_definitions(-DPNG_DEBUG)
endif()
2006-12-14 02:54:57 +00:00
2022-08-06 02:04:21 +00:00
if(NOT M_LIBRARY)
add_definitions(-DPNG_NO_FLOATING_POINT_SUPPORTED)
endif()
2006-12-14 02:54:57 +00:00
# NOW BUILD OUR TARGET
2022-08-06 02:04:21 +00:00
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()
2006-12-07 04:06:25 +00:00
2007-03-06 05:48:36 +00:00
# SET UP LINKS
2022-08-06 02:04:21 +00:00
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)