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/scripts/CMakeLists.txt

206 lines
5.4 KiB
CMake
Raw Normal View History

2006-12-14 02:54:57 +00:00
project(PNG)
2006-12-07 04:06:25 +00:00
2007-01-05 12:59:12 +00:00
# Copyright (C) 2007 Glenn Randers-Pehrson
# For conditions of distribution and use, see copyright notice in png.h
2006-12-14 02:54:57 +00:00
set(PNGLIB_MAJOR 1)
set(PNGLIB_MINOR 2)
2007-01-06 15:05:23 +00:00
set(PNGLIB_RELEASE 16)
2006-12-14 02:54:57 +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
# needed packages
find_package(ZLIB REQUIRED)
2006-12-14 02:54:57 +00:00
if(NOT WIN32)
find_library(M_LIBRARY
NAMES m
PATHS /usr/lib /usr/local/lib
)
if(NOT M_LIBRARY)
message(STATUS "math library 'libm' not found - floating point support disabled")
endif(NOT M_LIBRARY)
else(NOT WIN32)
# not needed on windows
set(M_LIBRARY "")
endif(NOT WIN32)
2006-12-07 04:06:25 +00:00
2006-12-14 02:54:57 +00:00
# COMMAND LINE OPTIONS
2006-12-08 01:21:29 +00:00
option(PNG_SHARED "Build shared lib" YES)
option(PNG_TESTS "Build pngtest" YES)
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" YES)
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 :)
2006-12-08 01:21:29 +00:00
set(png_asm_tmp "OFF")
if(NOT WIN32)
2006-12-14 02:54:57 +00:00
find_program(uname_executable NAMES uname PATHS /bin /usr/bin /usr/local/bin)
if(uname_executable)
EXEC_PROGRAM(${uname_executable} ARGS --machine OUTPUT_VARIABLE uname_output)
if("uname_output" MATCHES "^.*i[1-9]86.*$")
set(png_asm_tmp "ON")
else("uname_output" MATCHES "^.*i[1-9]86.*$")
set(png_asm_tmp "OFF")
endif("uname_output" MATCHES "^.*i[1-9]86.*$")
endif(uname_executable)
2006-12-08 01:21:29 +00:00
endif(NOT WIN32)
option(PNG_MMX "Use MMX assembler code (x86 only)" ${png_asm_tmp})
2006-12-14 02:54:57 +00:00
# SET LIBNAME
2006-12-07 04:06:25 +00:00
# msvc does not append 'lib' - do it here to have consistent name
if(MSVC)
2006-12-14 02:54:57 +00:00
set(PNG_LIB_NAME lib)
2006-12-07 04:06:25 +00:00
endif(MSVC)
2006-12-14 02:54:57 +00:00
set(PNG_LIB_NAME ${PNG_LIB_NAME}png${PNGLIB_MAJOR}${PNGLIB_MINOR})
2006-12-07 04:06:25 +00:00
# to distinguish between debug and release lib
set(CMAKE_DEBUG_POSTFIX "d")
# append _static to static lib
if(NOT PNG_SHARED)
2006-12-14 02:54:57 +00:00
set(PNG_LIB_NAME ${PNG_LIB_NAME}_static)
2006-12-07 04:06:25 +00:00
endif(NOT PNG_SHARED)
2007-01-17 03:04:40 +00:00
if(PNG_SHARED)
add_library(${PNG_LIB_NAME} SHARED ${libpng_sources})
else(PNG_SHARED)
add_library(${PNG_LIB_NAME} STATIC ${libpng_sources})
endif(PNG_SHARED)
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
2006-12-14 02:54:57 +00:00
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
)
set(pngtest_sources
2006-12-14 02:54:57 +00:00
pngtest.c
2006-12-07 04:06:25 +00:00
)
2006-12-14 02:54:57 +00:00
# SOME NEEDED DEFINITIONS
2006-12-07 04:06:25 +00:00
add_definitions(-DZLIB_DLL)
if(MSVC)
2006-12-14 02:54:57 +00:00
add_definitions(-DPNG_USE_PNGVCRD -DPNG_NO_MODULEDEF -D_CRT_SECURE_NO_DEPRECATE)
set(libpng_sources ${libpng_sources}
pngvcrd.c
)
2006-12-07 04:06:25 +00:00
else(MSVC)
2006-12-14 02:54:57 +00:00
add_definitions(-DPNG_USE_PNGGCCRD)
set(libpng_sources ${libpng_sources}
pnggccrd.c
)
2006-12-07 04:06:25 +00:00
endif(MSVC)
2006-12-14 02:54:57 +00:00
if(NOT MSVC)
if(NOT PNG_MMX)
add_definitions(-DLIBPNG_NO_MMX)
2006-12-18 20:08:10 +00:00
add_definitions(-DPNG_NO_MMX_CODE)
2006-12-14 02:54:57 +00:00
endif(NOT PNG_MMX)
else(NOT MSVC)
2006-12-18 20:08:10 +00:00
if(PNG_MMX)
2006-12-14 02:54:57 +00:00
# maybe add this to pngconf.h ?
add_definitions(-DPNG_MMX_CODE_SUPPORTED)
2006-12-18 20:08:10 +00:00
endif(PNG_MMX)
2006-12-14 02:54:57 +00:00
endif(NOT MSVC)
2006-12-08 01:21:29 +00:00
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(PNG_CONSOLE_IO_SUPPORTED)
if(PNG_NO_CONSOLE_IO)
add_definitions(-DPNG_NO_CONSOLE_IO)
endif(PNG_NO_CONSOLE_IO)
if(PNG_NO_STDIO)
add_definitions(-DPNG_NO_STDIO)
endif(PNG_NO_STDIO)
if(PNG_DEBUG)
add_definitions(-DPNG_DEBUG)
endif(PNG_DEBUG)
if(NOT M_LIBRARY)
add_definitions(-DPNG_NO_FLOATING_POINT_SUPPORTED)
endif(NOT M_LIBRARY)
# NOW BUILD OUR TARGET
include_directories(${PNG_SOURCE_DIR} ${ZLIB_INCLUDE_DIR})
2006-12-07 04:06:25 +00:00
if(PNG_SHARED)
2006-12-14 02:54:57 +00:00
add_library(${PNG_LIB_NAME} SHARED ${libpng_sources})
2006-12-07 04:06:25 +00:00
else(PNG_SHARED)
2006-12-14 02:54:57 +00:00
add_library(STATIC ${libpng_sources})
2006-12-07 04:06:25 +00:00
endif(PNG_SHARED)
2006-12-08 01:21:29 +00:00
target_link_libraries(${PNG_LIB_NAME} ${ZLIB_LIBRARY} ${M_LIBRARY})
if(PNG_SHARED AND WIN32)
2006-12-14 02:54:57 +00:00
set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
2006-12-08 01:21:29 +00:00
endif(PNG_SHARED AND WIN32)
2006-12-07 04:06:25 +00:00
if(PNG_TESTS)
# does not work with msvc due to png_lib_ver issue
2006-12-14 02:54:57 +00:00
add_executable(pngtest ${pngtest_sources})
target_link_libraries(pngtest ${PNG_LIB_NAME})
# add_test(pngtest ${PNG_SOURCE_DIR}/pngtest.png)
2006-12-07 04:06:25 +00:00
endif(PNG_TESTS)
2006-12-14 02:54:57 +00:00
# CREATE PKGCONFIG FILES
# we use the same files like ./configure, so we have to set its vars
set(prefix ${CMAKE_INSTALL_PREFIX}/bin)
set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin)
set(libdir ${CMAKE_INSTALL_PREFIX}/lib)
set(includedir ${CMAKE_INSTALL_PREFIX}/include)
configure_file(${PNG_SOURCE_DIR}/scripts/libpng.pc.in ${PNG_BINARY_DIR}/libpng.pc)
configure_file(${PNG_SOURCE_DIR}/scripts/libpng-config.in ${PNG_BINARY_DIR}/libpng-config)
configure_file(${PNG_SOURCE_DIR}/scripts/libpng.pc.in ${PNG_BINARY_DIR}/${PNGLIB_NAME}.pc)
configure_file(${PNG_SOURCE_DIR}/scripts/libpng-config.in ${PNG_BINARY_DIR}/${PNGLIB_NAME}-config)
# INSTALL
install_targets(/lib ${PNG_LIB_NAME})
install(FILES png.h pngconf.h DESTINATION include)
install(FILES png.h pngconf.h DESTINATION include/${PNGLIB_NAME})
install(FILES libpng.3 libpngpf.3 DESTINATION man/man3)
2007-01-17 03:04:40 +00:00
install(FILES png.5 DESTINATION man/man5)
2006-12-14 02:54:57 +00:00
install(FILES ${PNG_BINARY_DIR}/libpng.pc DESTINATION lib/pkgconfig)
install(FILES ${PNG_BINARY_DIR}/libpng-config DESTINATION bin)
install(FILES ${PNG_BINARY_DIR}/${PNGLIB_NAME}.pc DESTINATION lib/pkgconfig)
install(FILES ${PNG_BINARY_DIR}/${PNGLIB_NAME}-config DESTINATION bin)
2006-12-07 04:06:25 +00:00
# what's with libpng.txt and all the extra files?
2006-12-14 02:54:57 +00:00
# UNINSTALL
2006-12-07 04:06:25 +00:00
# do we need this?
2006-12-14 02:54:57 +00:00
# DIST
2006-12-07 04:06:25 +00: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