~ubuntu-branches/ubuntu/maverick/libpng/maverick-security

« back to all changes in this revision

Viewing changes to scripts/CMakeLists.txt

  • Committer: Bazaar Package Importer
  • Author(s): Anibal Monsalve Salazar
  • Date: 2009-12-04 11:23:50 UTC
  • mfrom: (1.1.10 upstream) (15.2.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091204112350-ln22xyakgn9bh39k
Tags: 1.2.41-1
* New upstream release
* Debian source format is 3.0 (quilt)
* Update debian/watch
* Add 02-export-png_set_strip_error_numbers.patch
  Define PNG_ERROR_NUMBERS_SUPPORTED
  Upstream doesn't define PNG_ERROR_NUMBERS_SUPPORTED since 1.2.41. As
  a consecuence, the symbol png_set_strip_error_numbe@@PNG12_0 wasn't
  exported.

Show diffs side-by-side

added added

removed removed

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