]> git.saurik.com Git - wxWidgets.git/blame - src/png/scripts/CMakeLists.txt
better variant support, fixes #11114
[wxWidgets.git] / src / png / scripts / CMakeLists.txt
CommitLineData
0272a10d
VZ
1
2project(PNG)
3
4# Copyright (C) 2007 Glenn Randers-Pehrson
5# For conditions of distribution and use, see copyright notice in png.h
6
7set(PNGLIB_MAJOR 1)
8set(PNGLIB_MINOR 2)
970f6abe 9set(PNGLIB_RELEASE 34)
0272a10d
VZ
10set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
11set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
12
13# needed packages
14find_package(ZLIB REQUIRED)
15if(NOT WIN32)
16 find_library(M_LIBRARY
17 NAMES m
18 PATHS /usr/lib /usr/local/lib
19 )
20 if(NOT M_LIBRARY)
21 message(STATUS
22 "math library 'libm' not found - floating point support disabled")
23 endif(NOT M_LIBRARY)
24else(NOT WIN32)
25 # not needed on windows
26 set(M_LIBRARY "")
27endif(NOT WIN32)
28
29
30# COMMAND LINE OPTIONS
31option(PNG_SHARED "Build shared lib" YES)
32option(PNG_STATIC "Build static lib" YES)
33if(MINGW)
34 option(PNG_TESTS "Build pngtest" NO)
35else(MINGW)
36 option(PNG_TESTS "Build pngtest" YES)
37endif(MINGW)
38option(PNG_NO_CONSOLE_IO "FIXME" YES)
39option(PNG_NO_STDIO "FIXME" YES)
40option(PNG_DEBUG "Build with debug output" YES)
41option(PNGARG "FIXME" YES)
42#TODO:
43# PNG_CONSOLE_IO_SUPPORTED
44
45# maybe needs improving, but currently I don't know when we can enable what :)
46set(png_asm_tmp "OFF")
47if(NOT WIN32)
48 find_program(uname_executable NAMES uname PATHS /bin /usr/bin /usr/local/bin)
49 if(uname_executable)
50 EXEC_PROGRAM(${uname_executable} ARGS --machine OUTPUT_VARIABLE uname_output)
51 if("uname_output" MATCHES "^.*i[1-9]86.*$")
52 set(png_asm_tmp "ON")
53 else("uname_output" MATCHES "^.*i[1-9]86.*$")
54 set(png_asm_tmp "OFF")
55 endif("uname_output" MATCHES "^.*i[1-9]86.*$")
56 endif(uname_executable)
57else(NOT WIN32)
58 # this env var is normally only set on win64
59 SET(TEXT "ProgramFiles(x86)")
60 if("$ENV{${TEXT}}" STREQUAL "")
61 set(png_asm_tmp "ON")
62 endif("$ENV{${TEXT}}" STREQUAL "")
63endif(NOT WIN32)
64
65# SET LIBNAME
66# msvc does not append 'lib' - do it here to have consistent name
67if(MSVC)
68 set(PNG_LIB_NAME lib)
69endif(MSVC)
70set(PNG_LIB_NAME ${PNG_LIB_NAME}png${PNGLIB_MAJOR}${PNGLIB_MINOR})
71
72# to distinguish between debug and release lib
73set(CMAKE_DEBUG_POSTFIX "d")
74
75
76# OUR SOURCES
77set(libpng_sources
78 png.h
79 pngconf.h
80 png.c
81 pngerror.c
82 pngget.c
83 pngmem.c
84 pngpread.c
85 pngread.c
86 pngrio.c
87 pngrtran.c
88 pngrutil.c
89 pngset.c
90 pngtrans.c
91 pngwio.c
92 pngwrite.c
93 pngwtran.c
94 pngwutil.c
95)
96set(pngtest_sources
97 pngtest.c
98)
99# SOME NEEDED DEFINITIONS
100if(MSVC)
101 add_definitions(-DPNG_NO_MODULEDEF -D_CRT_SECURE_NO_DEPRECATE)
102endif(MSVC)
103
104add_definitions(-DZLIB_DLL)
105
106add_definitions(-DLIBPNG_NO_MMX)
107add_definitions(-DPNG_NO_MMX_CODE)
108
109if(PNG_CONSOLE_IO_SUPPORTED)
110 add_definitions(-DPNG_CONSOLE_IO_SUPPORTED)
111endif(PNG_CONSOLE_IO_SUPPORTED)
112
113if(PNG_NO_CONSOLE_IO)
114 add_definitions(-DPNG_NO_CONSOLE_IO)
115endif(PNG_NO_CONSOLE_IO)
116
117if(PNG_NO_STDIO)
118 add_definitions(-DPNG_NO_STDIO)
119endif(PNG_NO_STDIO)
120
121if(PNG_DEBUG)
122 add_definitions(-DPNG_DEBUG)
123endif(PNG_DEBUG)
124
125if(NOT M_LIBRARY AND NOT WIN32)
126 add_definitions(-DPNG_NO_FLOATING_POINT_SUPPORTED)
127endif(NOT M_LIBRARY AND NOT WIN32)
128
129# NOW BUILD OUR TARGET
130include_directories(${PNG_SOURCE_DIR} ${ZLIB_INCLUDE_DIR})
131
132if(PNG_SHARED)
133 add_library(${PNG_LIB_NAME} SHARED ${libpng_sources})
134 target_link_libraries(${PNG_LIB_NAME} ${ZLIB_LIBRARY} ${M_LIBRARY})
135endif(PNG_SHARED)
136if(PNG_STATIC)
137# does not work without changing name
138 set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME}_static)
139 add_library(${PNG_LIB_NAME_STATIC} STATIC ${libpng_sources})
140endif(PNG_STATIC)
141
142if(PNG_SHARED AND WIN32)
143 set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
144endif(PNG_SHARED AND WIN32)
145
146if(PNG_TESTS)
147# does not work with msvc due to png_lib_ver issue
148 add_executable(pngtest ${pngtest_sources})
149 target_link_libraries(pngtest ${PNG_LIB_NAME})
150# add_test(pngtest ${PNG_SOURCE_DIR}/pngtest.png)
151endif(PNG_TESTS)
152
153
154# CREATE PKGCONFIG FILES
155# we use the same files like ./configure, so we have to set its vars
156set(prefix ${CMAKE_INSTALL_PREFIX})
157set(exec_prefix ${CMAKE_INSTALL_PREFIX})
158set(libdir ${CMAKE_INSTALL_PREFIX}/lib)
159set(includedir ${CMAKE_INSTALL_PREFIX}/include)
160
161configure_file(${PNG_SOURCE_DIR}/scripts/libpng.pc.in
162 ${PNG_BINARY_DIR}/libpng.pc)
163configure_file(${PNG_SOURCE_DIR}/scripts/libpng-config.in
164 ${PNG_BINARY_DIR}/libpng-config)
165configure_file(${PNG_SOURCE_DIR}/scripts/libpng.pc.in
166 ${PNG_BINARY_DIR}/${PNGLIB_NAME}.pc)
167configure_file(${PNG_SOURCE_DIR}/scripts/libpng-config.in
168 ${PNG_BINARY_DIR}/${PNGLIB_NAME}-config)
169
170# SET UP LINKS
171set_target_properties(${PNG_LIB_NAME} PROPERTIES
970f6abe 172# VERSION 0.${PNGLIB_RELEASE}.1.2.34
0272a10d
VZ
173 VERSION 0.${PNGLIB_RELEASE}.0
174 SOVERSION 0
175 CLEAN_DIRECT_OUTPUT 1)
176if(NOT WIN32)
177 # that's uncool on win32 - it overwrites our static import lib...
178 set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES
179 OUTPUT_NAME ${PNG_LIB_NAME}
180 CLEAN_DIRECT_OUTPUT 1)
181endif(NOT WIN32)
182# INSTALL
183install_targets(/lib ${PNG_LIB_NAME})
184if(PNG_STATIC)
185 install_targets(/lib ${PNG_LIB_NAME_STATIC})
186endif(PNG_STATIC)
187
188install(FILES png.h pngconf.h DESTINATION include)
189install(FILES png.h pngconf.h DESTINATION include/${PNGLIB_NAME})
190install(FILES libpng.3 libpngpf.3 DESTINATION man/man3)
191install(FILES png.5 DESTINATION man/man5)
192install(FILES ${PNG_BINARY_DIR}/libpng.pc DESTINATION lib/pkgconfig)
193install(FILES ${PNG_BINARY_DIR}/libpng-config DESTINATION bin)
194install(FILES ${PNG_BINARY_DIR}/${PNGLIB_NAME}.pc DESTINATION lib/pkgconfig)
195install(FILES ${PNG_BINARY_DIR}/${PNGLIB_NAME}-config DESTINATION bin)
196
197# what's with libpng.txt and all the extra files?
198
199
200# UNINSTALL
201# do we need this?
202
203
204# DIST
205# do we need this?
206
207# to create msvc import lib for mingw compiled shared lib
208# pexports libpng.dll > libpng.def
209# lib /def:libpng.def /machine:x86
210