1 |
|
---|
2 | # CMakeLists.txt - CMake lists for libpng
|
---|
3 | #
|
---|
4 | # Copyright (c) 2018-2024 Cosmin Truta.
|
---|
5 | # Copyright (c) 2007-2018 Glenn Randers-Pehrson.
|
---|
6 | # Originally written by Christian Ehrlicher, 2007.
|
---|
7 | #
|
---|
8 | # Use, modification and distribution are subject to
|
---|
9 | # the same licensing terms and conditions as libpng.
|
---|
10 | # Please see the copyright notice in png.h or visit
|
---|
11 | # http://libpng.org/pub/png/src/libpng-LICENSE.txt
|
---|
12 | #
|
---|
13 | # For copyright and licensing purposes, please see
|
---|
14 | # the accompanying file scripts/cmake/AUTHORS.md
|
---|
15 | #
|
---|
16 | # SPDX-License-Identifier: libpng-2.0
|
---|
17 |
|
---|
18 | cmake_minimum_required(VERSION 3.6)
|
---|
19 |
|
---|
20 | set(PNGLIB_MAJOR 1)
|
---|
21 | set(PNGLIB_MINOR 6)
|
---|
22 | set(PNGLIB_REVISION 41)
|
---|
23 | set(PNGLIB_SUBREVISION 0)
|
---|
24 | #set(PNGLIB_SUBREVISION "git")
|
---|
25 | set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_REVISION})
|
---|
26 | set(PNGLIB_ABI_VERSION ${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
---|
27 | set(PNGLIB_SHARED_VERSION ${PNGLIB_ABI_VERSION}.${PNGLIB_REVISION}.${PNGLIB_SUBREVISION})
|
---|
28 |
|
---|
29 | project(libpng
|
---|
30 | VERSION ${PNGLIB_VERSION}
|
---|
31 | LANGUAGES C ASM)
|
---|
32 |
|
---|
33 | if(POLICY CMP0074)
|
---|
34 | # Allow find_package() to use the ZLIB_ROOT variable, if available.
|
---|
35 | cmake_policy(SET CMP0074 NEW)
|
---|
36 | endif()
|
---|
37 |
|
---|
38 | include(CheckCSourceCompiles)
|
---|
39 | include(GNUInstallDirs)
|
---|
40 |
|
---|
41 | # Allow the users to specify an application-specific API prefix for libpng
|
---|
42 | # vendoring purposes. A standard libpng build should have no such prefix.
|
---|
43 | set(PNG_PREFIX ""
|
---|
44 | CACHE STRING "Prefix to prepend to the API function names")
|
---|
45 |
|
---|
46 | # Allow the users to override the postfix appended to debug library file names.
|
---|
47 | # Previously, we used to set CMAKE_DEBUG_POSTFIX globally. That variable should
|
---|
48 | # not be cached, however, because doing so would affect all projects processed
|
---|
49 | # after libpng, in unexpected and undesirable ways.
|
---|
50 | set(PNG_DEBUG_POSTFIX "d"
|
---|
51 | CACHE STRING "Postfix to append to library file names under the Debug configuration")
|
---|
52 |
|
---|
53 | # Allow the users to import their own extra configuration settings.
|
---|
54 | set(DFA_XTRA ""
|
---|
55 | CACHE FILEPATH "File containing extra configuration settings")
|
---|
56 |
|
---|
57 | # Allow the users to switch on/off various library build types.
|
---|
58 | option(PNG_SHARED "Build libpng as a shared library" ON)
|
---|
59 | option(PNG_STATIC "Build libpng as a static library" ON)
|
---|
60 | if(APPLE)
|
---|
61 | option(PNG_FRAMEWORK "Build libpng as a framework bundle" ON)
|
---|
62 | endif()
|
---|
63 |
|
---|
64 | # Allow the users to switch on/off the auxiliary build and test artifacts.
|
---|
65 | # NOTE: These artifacts are NOT part of libpng proper, and are subject to change at any time.
|
---|
66 | option(PNG_TESTS "Build the libpng tests" ON)
|
---|
67 | option(PNG_TOOLS "Build the libpng tools" ON)
|
---|
68 |
|
---|
69 | # Maintain backwards compatibility with the deprecated option PNG_EXECUTABLES.
|
---|
70 | option(PNG_EXECUTABLES "[Deprecated; please use PNG_TOOLS]" ON)
|
---|
71 | if(NOT PNG_EXECUTABLES)
|
---|
72 | message(DEPRECATION "The option PNG_EXECUTABLES has been deprecated in favour of PNG_TOOLS")
|
---|
73 | if(PNG_TOOLS)
|
---|
74 | message(AUTHOR_WARNING
|
---|
75 | "Setting PNG_TOOLS to ${PNG_EXECUTABLES}, to stay compatible with PNG_EXECUTABLES")
|
---|
76 | set(PNG_TOOLS "${PNG_EXECUTABLES}")
|
---|
77 | endif()
|
---|
78 | endif()
|
---|
79 |
|
---|
80 | # Allow the users to configure various compilation options.
|
---|
81 | option(PNG_DEBUG "Enable debug output" OFF)
|
---|
82 | option(PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations" ON)
|
---|
83 |
|
---|
84 | # Allow the users to specify a custom location of zlib.
|
---|
85 | # This option is deprecated, and no longer needed with CMake 3.12 and newer.
|
---|
86 | # Under the CMake policy CMP0074, if zlib is being built alongside libpng as a
|
---|
87 | # subproject, its location can be passed on to CMake via the ZLIB_ROOT variable.
|
---|
88 | option(PNG_BUILD_ZLIB "Custom zlib location, else find_package is used" OFF)
|
---|
89 | if(NOT PNG_BUILD_ZLIB)
|
---|
90 | find_package(ZLIB REQUIRED)
|
---|
91 | elseif(POLICY CMP0074)
|
---|
92 | # TODO: Remove the policy check if CMake version 3.12 or greater becomes the minimum required.
|
---|
93 | if("x${ZLIB_ROOT}" STREQUAL "x")
|
---|
94 | message(DEPRECATION
|
---|
95 | "The option PNG_BUILD_ZLIB has been deprecated; please use ZLIB_ROOT instead")
|
---|
96 | else()
|
---|
97 | message(SEND_ERROR
|
---|
98 | "The option PNG_BUILD_ZLIB=${PNG_BUILD_ZLIB} and "
|
---|
99 | "the variable ZLIB_ROOT=\"${ZLIB_ROOT}\" are mutually exclusive")
|
---|
100 | endif()
|
---|
101 | endif()
|
---|
102 |
|
---|
103 | if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU AND NOT EMSCRIPTEN)
|
---|
104 | find_library(M_LIBRARY m)
|
---|
105 | if(M_LIBRARY)
|
---|
106 | set(M_LIBRARY m)
|
---|
107 | else()
|
---|
108 | set(M_LIBRARY "")
|
---|
109 | endif()
|
---|
110 | else()
|
---|
111 | # libm is not available or not needed.
|
---|
112 | endif()
|
---|
113 |
|
---|
114 | # CMake currently sets CMAKE_SYSTEM_PROCESSOR to one of x86_64 or arm64 on macOS,
|
---|
115 | # based upon the OS architecture, not the target architecture. As such, we need
|
---|
116 | # to check CMAKE_OSX_ARCHITECTURES to identify which hardware-specific flags to
|
---|
117 | # enable. Note that this will fail if you attempt to build a universal binary in
|
---|
118 | # a single CMake invocation.
|
---|
119 | if (APPLE AND CMAKE_OSX_ARCHITECTURES)
|
---|
120 | set(TARGET_ARCH ${CMAKE_OSX_ARCHITECTURES})
|
---|
121 | else()
|
---|
122 | set(TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR})
|
---|
123 | endif()
|
---|
124 |
|
---|
125 | if(PNG_HARDWARE_OPTIMIZATIONS)
|
---|
126 |
|
---|
127 | # Set definitions and sources for ARM.
|
---|
128 | if(TARGET_ARCH MATCHES "^(ARM|arm|aarch)")
|
---|
129 | if(TARGET_ARCH MATCHES "^(ARM64|arm64|aarch64)")
|
---|
130 | set(PNG_ARM_NEON_POSSIBLE_VALUES on off)
|
---|
131 | set(PNG_ARM_NEON "on"
|
---|
132 | CACHE STRING "Enable ARM NEON optimizations: on|off; on is default")
|
---|
133 | else()
|
---|
134 | set(PNG_ARM_NEON_POSSIBLE_VALUES check on off)
|
---|
135 | set(PNG_ARM_NEON "off"
|
---|
136 | CACHE STRING "Enable ARM NEON optimizations: check|on|off; off is default")
|
---|
137 | endif()
|
---|
138 | set_property(CACHE PNG_ARM_NEON
|
---|
139 | PROPERTY STRINGS ${PNG_ARM_NEON_POSSIBLE_VALUES})
|
---|
140 | list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index)
|
---|
141 | if(index EQUAL -1)
|
---|
142 | message(FATAL_ERROR "PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]")
|
---|
143 | elseif(NOT PNG_ARM_NEON STREQUAL "off")
|
---|
144 | set(libpng_arm_sources
|
---|
145 | arm/arm_init.c
|
---|
146 | arm/filter_neon_intrinsics.c
|
---|
147 | arm/palette_neon_intrinsics.c)
|
---|
148 | if(NOT MSVC)
|
---|
149 | list(APPEND libpng_arm_sources arm/filter_neon.S)
|
---|
150 | endif()
|
---|
151 | if(PNG_ARM_NEON STREQUAL "on")
|
---|
152 | add_definitions(-DPNG_ARM_NEON_OPT=2)
|
---|
153 | elseif(PNG_ARM_NEON STREQUAL "check")
|
---|
154 | add_definitions(-DPNG_ARM_NEON_CHECK_SUPPORTED)
|
---|
155 | endif()
|
---|
156 | else()
|
---|
157 | add_definitions(-DPNG_ARM_NEON_OPT=0)
|
---|
158 | endif()
|
---|
159 | endif()
|
---|
160 |
|
---|
161 | # Set definitions and sources for PowerPC.
|
---|
162 | if(TARGET_ARCH MATCHES "^(powerpc|ppc64)")
|
---|
163 | set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off)
|
---|
164 | set(PNG_POWERPC_VSX "on"
|
---|
165 | CACHE STRING "Enable POWERPC VSX optimizations: on|off; on is default")
|
---|
166 | set_property(CACHE PNG_POWERPC_VSX
|
---|
167 | PROPERTY STRINGS ${PNG_POWERPC_VSX_POSSIBLE_VALUES})
|
---|
168 | list(FIND PNG_POWERPC_VSX_POSSIBLE_VALUES ${PNG_POWERPC_VSX} index)
|
---|
169 | if(index EQUAL -1)
|
---|
170 | message(FATAL_ERROR "PNG_POWERPC_VSX must be one of [${PNG_POWERPC_VSX_POSSIBLE_VALUES}]")
|
---|
171 | elseif(NOT PNG_POWERPC_VSX STREQUAL "off")
|
---|
172 | set(libpng_powerpc_sources
|
---|
173 | powerpc/powerpc_init.c
|
---|
174 | powerpc/filter_vsx_intrinsics.c)
|
---|
175 | if(PNG_POWERPC_VSX STREQUAL "on")
|
---|
176 | add_definitions(-DPNG_POWERPC_VSX_OPT=2)
|
---|
177 | endif()
|
---|
178 | else()
|
---|
179 | add_definitions(-DPNG_POWERPC_VSX_OPT=0)
|
---|
180 | endif()
|
---|
181 | endif()
|
---|
182 |
|
---|
183 | # Set definitions and sources for Intel.
|
---|
184 | if(TARGET_ARCH MATCHES "^(i[3-6]86|x86|AMD64)")
|
---|
185 | set(PNG_INTEL_SSE_POSSIBLE_VALUES on off)
|
---|
186 | set(PNG_INTEL_SSE "on"
|
---|
187 | CACHE STRING "Enable INTEL_SSE optimizations: on|off; on is default")
|
---|
188 | set_property(CACHE PNG_INTEL_SSE
|
---|
189 | PROPERTY STRINGS ${PNG_INTEL_SSE_POSSIBLE_VALUES})
|
---|
190 | list(FIND PNG_INTEL_SSE_POSSIBLE_VALUES ${PNG_INTEL_SSE} index)
|
---|
191 | if(index EQUAL -1)
|
---|
192 | message(FATAL_ERROR "PNG_INTEL_SSE must be one of [${PNG_INTEL_SSE_POSSIBLE_VALUES}]")
|
---|
193 | elseif(NOT PNG_INTEL_SSE STREQUAL "off")
|
---|
194 | set(libpng_intel_sources
|
---|
195 | intel/intel_init.c
|
---|
196 | intel/filter_sse2_intrinsics.c)
|
---|
197 | if(PNG_INTEL_SSE STREQUAL "on")
|
---|
198 | add_definitions(-DPNG_INTEL_SSE_OPT=1)
|
---|
199 | endif()
|
---|
200 | else()
|
---|
201 | add_definitions(-DPNG_INTEL_SSE_OPT=0)
|
---|
202 | endif()
|
---|
203 | endif()
|
---|
204 |
|
---|
205 | # Set definitions and sources for MIPS.
|
---|
206 | if(TARGET_ARCH MATCHES "^(mipsel|mips64el)")
|
---|
207 | set(PNG_MIPS_MSA_POSSIBLE_VALUES on off)
|
---|
208 | set(PNG_MIPS_MSA "on"
|
---|
209 | CACHE STRING "Enable MIPS_MSA optimizations: on|off; on is default")
|
---|
210 | set_property(CACHE PNG_MIPS_MSA
|
---|
211 | PROPERTY STRINGS ${PNG_MIPS_MSA_POSSIBLE_VALUES})
|
---|
212 | list(FIND PNG_MIPS_MSA_POSSIBLE_VALUES ${PNG_MIPS_MSA} index_msa)
|
---|
213 | if(index_msa EQUAL -1)
|
---|
214 | message(FATAL_ERROR "PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]")
|
---|
215 | endif()
|
---|
216 |
|
---|
217 | set(PNG_MIPS_MMI_POSSIBLE_VALUES on off)
|
---|
218 | set(PNG_MIPS_MMI "on"
|
---|
219 | CACHE STRING "Enable MIPS_MMI optimizations: on|off; on is default")
|
---|
220 | set_property(CACHE PNG_MIPS_MMI
|
---|
221 | PROPERTY STRINGS ${PNG_MIPS_MMI_POSSIBLE_VALUES})
|
---|
222 | list(FIND PNG_MIPS_MMI_POSSIBLE_VALUES ${PNG_MIPS_MMI} index_mmi)
|
---|
223 | if(index_mmi EQUAL -1)
|
---|
224 | message(FATAL_ERROR "PNG_MIPS_MMI must be one of [${PNG_MIPS_MMI_POSSIBLE_VALUES}]")
|
---|
225 | endif()
|
---|
226 |
|
---|
227 | if(PNG_MIPS_MSA STREQUAL "on" AND PNG_MIPS_MMI STREQUAL "on")
|
---|
228 | set(libpng_mips_sources
|
---|
229 | mips/mips_init.c
|
---|
230 | mips/filter_msa_intrinsics.c
|
---|
231 | mips/filter_mmi_inline_assembly.c)
|
---|
232 | add_definitions(-DPNG_MIPS_MSA_OPT=2)
|
---|
233 | add_definitions(-DPNG_MIPS_MMI_OPT=1)
|
---|
234 | elseif(PNG_MIPS_MSA STREQUAL "on")
|
---|
235 | set(libpng_mips_sources
|
---|
236 | mips/mips_init.c
|
---|
237 | mips/filter_msa_intrinsics.c)
|
---|
238 | add_definitions(-DPNG_MIPS_MSA_OPT=2)
|
---|
239 | add_definitions(-DPNG_MIPS_MMI_OPT=0)
|
---|
240 | elseif(PNG_MIPS_MMI STREQUAL "on")
|
---|
241 | set(libpng_mips_sources
|
---|
242 | mips/mips_init.c
|
---|
243 | mips/filter_mmi_inline_assembly.c)
|
---|
244 | add_definitions(-DPNG_MIPS_MSA_OPT=0)
|
---|
245 | add_definitions(-DPNG_MIPS_MMI_OPT=1)
|
---|
246 | else()
|
---|
247 | add_definitions(-DPNG_MIPS_MSA_OPT=0)
|
---|
248 | add_definitions(-DPNG_MIPS_MMI_OPT=0)
|
---|
249 | endif()
|
---|
250 | endif()
|
---|
251 |
|
---|
252 | else(PNG_HARDWARE_OPTIMIZATIONS)
|
---|
253 |
|
---|
254 | # Set definitions and sources for ARM.
|
---|
255 | if(TARGET_ARCH MATCHES "^(ARM|arm|aarch)")
|
---|
256 | add_definitions(-DPNG_ARM_NEON_OPT=0)
|
---|
257 | endif()
|
---|
258 |
|
---|
259 | # Set definitions and sources for PowerPC.
|
---|
260 | if(TARGET_ARCH MATCHES "^(powerpc|ppc64)")
|
---|
261 | add_definitions(-DPNG_POWERPC_VSX_OPT=0)
|
---|
262 | endif()
|
---|
263 |
|
---|
264 | # Set definitions and sources for Intel.
|
---|
265 | if(TARGET_ARCH MATCHES "^(i[3-6]86|x86|AMD64)")
|
---|
266 | add_definitions(-DPNG_INTEL_SSE_OPT=0)
|
---|
267 | endif()
|
---|
268 |
|
---|
269 | # Set definitions and sources for MIPS.
|
---|
270 | if(TARGET_ARCH MATCHES "^(mipsel|mips64el)")
|
---|
271 | add_definitions(-DPNG_MIPS_MSA_OPT=0)
|
---|
272 | endif()
|
---|
273 |
|
---|
274 | endif(PNG_HARDWARE_OPTIMIZATIONS)
|
---|
275 |
|
---|
276 | option(ld-version-script "Enable linker version script" ON)
|
---|
277 | if(ld-version-script AND NOT ANDROID AND NOT APPLE)
|
---|
278 | # Check if LD supports linker scripts.
|
---|
279 | file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "
|
---|
280 | VERS_1 { global: sym1; local: *; };
|
---|
281 | VERS_2 { global: sym2; main; } VERS_1;
|
---|
282 | ")
|
---|
283 | set(_SAVED_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
---|
284 | if(NOT CMAKE_HOST_SOLARIS)
|
---|
285 | # Avoid using CMAKE_SHARED_LIBRARY_C_FLAGS in version script checks on
|
---|
286 | # Solaris, because of an incompatibility with the Solaris link editor.
|
---|
287 | list(APPEND CMAKE_REQUIRED_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS})
|
---|
288 | endif()
|
---|
289 | list(APPEND CMAKE_REQUIRED_FLAGS "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'")
|
---|
290 | check_c_source_compiles("
|
---|
291 | void sym1(void) {}
|
---|
292 | void sym2(void) {}
|
---|
293 | int main(void) { return 0; }
|
---|
294 | " HAVE_LD_VERSION_SCRIPT)
|
---|
295 | if(NOT HAVE_LD_VERSION_SCRIPT)
|
---|
296 | set(CMAKE_REQUIRED_FLAGS ${_SAVED_CMAKE_REQUIRED_FLAGS})
|
---|
297 | if(NOT CMAKE_HOST_SOLARIS)
|
---|
298 | # Again, avoid using CMAKE_SHARED_LIBRARY_C_FLAGS in version script
|
---|
299 | # checks on Solaris.
|
---|
300 | list(APPEND CMAKE_REQUIRED_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS})
|
---|
301 | endif()
|
---|
302 | list(APPEND CMAKE_REQUIRED_FLAGS "-Wl,-M -Wl,${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
|
---|
303 | check_c_source_compiles("
|
---|
304 | void sym1(void) {}
|
---|
305 | void sym2(void) {}
|
---|
306 | int main(void) { return 0; }
|
---|
307 | " HAVE_SOLARIS_LD_VERSION_SCRIPT)
|
---|
308 | endif()
|
---|
309 | set(CMAKE_REQUIRED_FLAGS ${_SAVED_CMAKE_REQUIRED_FLAGS})
|
---|
310 | file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
|
---|
311 | endif()
|
---|
312 |
|
---|
313 | find_program(AWK NAMES gawk awk)
|
---|
314 |
|
---|
315 | include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
---|
316 |
|
---|
317 | if(NOT AWK OR ANDROID OR IOS)
|
---|
318 | # No awk available to generate sources; use pre-built pnglibconf.h
|
---|
319 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
|
---|
320 | ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h)
|
---|
321 | add_custom_target(png_genfiles)
|
---|
322 | else()
|
---|
323 | # Copy the awk scripts, converting their line endings to Unix (LF)
|
---|
324 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk
|
---|
325 | ${CMAKE_CURRENT_BINARY_DIR}/scripts/checksym.awk
|
---|
326 | @ONLY
|
---|
327 | NEWLINE_STYLE LF)
|
---|
328 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk
|
---|
329 | ${CMAKE_CURRENT_BINARY_DIR}/scripts/options.awk
|
---|
330 | @ONLY
|
---|
331 | NEWLINE_STYLE LF)
|
---|
332 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/dfn.awk
|
---|
333 | ${CMAKE_CURRENT_BINARY_DIR}/scripts/dfn.awk
|
---|
334 | @ONLY
|
---|
335 | NEWLINE_STYLE LF)
|
---|
336 |
|
---|
337 | # Generate .chk from .out with awk:
|
---|
338 | # generate_chk(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
|
---|
339 | function(generate_chk)
|
---|
340 | set(options)
|
---|
341 | set(oneValueArgs INPUT OUTPUT)
|
---|
342 | set(multiValueArgs DEPENDS)
|
---|
343 | cmake_parse_arguments(_GC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
---|
344 | if(NOT _GC_INPUT)
|
---|
345 | message(FATAL_ERROR "generate_chk: Missing INPUT argument")
|
---|
346 | endif()
|
---|
347 | if(NOT _GC_OUTPUT)
|
---|
348 | message(FATAL_ERROR "generate_chk: Missing OUTPUT argument")
|
---|
349 | endif()
|
---|
350 |
|
---|
351 | add_custom_command(OUTPUT "${_GC_OUTPUT}"
|
---|
352 | COMMAND "${CMAKE_COMMAND}"
|
---|
353 | "-DINPUT=${_GC_INPUT}"
|
---|
354 | "-DOUTPUT=${_GC_OUTPUT}"
|
---|
355 | -P "${CMAKE_CURRENT_BINARY_DIR}/genchk.cmake"
|
---|
356 | DEPENDS "${_GC_INPUT}" ${_GC_DEPENDS}
|
---|
357 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
---|
358 | endfunction()
|
---|
359 |
|
---|
360 | # Generate .out from .c with awk
|
---|
361 | # generate_out(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
|
---|
362 | function(generate_out)
|
---|
363 | set(options)
|
---|
364 | set(oneValueArgs INPUT OUTPUT)
|
---|
365 | set(multiValueArgs DEPENDS)
|
---|
366 | cmake_parse_arguments(_GO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
---|
367 | if(NOT _GO_INPUT)
|
---|
368 | message(FATAL_ERROR "generate_out: Missing INPUT argument")
|
---|
369 | endif()
|
---|
370 | if(NOT _GO_OUTPUT)
|
---|
371 | message(FATAL_ERROR "generate_out: Missing OUTPUT argument")
|
---|
372 | endif()
|
---|
373 |
|
---|
374 | add_custom_command(OUTPUT "${_GO_OUTPUT}"
|
---|
375 | COMMAND "${CMAKE_COMMAND}"
|
---|
376 | "-DINPUT=${_GO_INPUT}"
|
---|
377 | "-DOUTPUT=${_GO_OUTPUT}"
|
---|
378 | -P "${CMAKE_CURRENT_BINARY_DIR}/genout.cmake"
|
---|
379 | DEPENDS "${_GO_INPUT}" ${_GO_DEPENDS}
|
---|
380 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
---|
381 | endfunction()
|
---|
382 |
|
---|
383 | # Generate specific source file with awk
|
---|
384 | # generate_source(OUTPUT outputfile [DEPENDS dep1 [dep2...]])
|
---|
385 | function(generate_source)
|
---|
386 | set(options)
|
---|
387 | set(oneValueArgs OUTPUT)
|
---|
388 | set(multiValueArgs DEPENDS)
|
---|
389 | cmake_parse_arguments(_GSO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
---|
390 | if(NOT _GSO_OUTPUT)
|
---|
391 | message(FATAL_ERROR "generate_source: Missing OUTPUT argument")
|
---|
392 | endif()
|
---|
393 |
|
---|
394 | add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}"
|
---|
395 | COMMAND "${CMAKE_COMMAND}"
|
---|
396 | "-DOUTPUT=${_GSO_OUTPUT}"
|
---|
397 | -P "${CMAKE_CURRENT_BINARY_DIR}/gensrc.cmake"
|
---|
398 | DEPENDS ${_GSO_DEPENDS}
|
---|
399 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
---|
400 | endfunction()
|
---|
401 |
|
---|
402 | # Copy file
|
---|
403 | # generate_copy(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
|
---|
404 | function(generate_copy)
|
---|
405 | set(options)
|
---|
406 | set(oneValueArgs INPUT OUTPUT)
|
---|
407 | set(multiValueArgs DEPENDS)
|
---|
408 | cmake_parse_arguments(_GCO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
---|
409 | if(NOT _GCO_INPUT)
|
---|
410 | message(FATAL_ERROR "generate_copy: Missing INPUT argument")
|
---|
411 | endif()
|
---|
412 | if(NOT _GCO_OUTPUT)
|
---|
413 | message(FATAL_ERROR "generate_copy: Missing OUTPUT argument")
|
---|
414 | endif()
|
---|
415 |
|
---|
416 | add_custom_command(OUTPUT "${_GCO_OUTPUT}"
|
---|
417 | COMMAND "${CMAKE_COMMAND}"
|
---|
418 | -E remove "${_GCO_OUTPUT}"
|
---|
419 | COMMAND "${CMAKE_COMMAND}"
|
---|
420 | -E copy "${_GCO_INPUT}" "${_GCO_OUTPUT}"
|
---|
421 | DEPENDS "${source}" ${_GCO_DEPENDS})
|
---|
422 | endfunction()
|
---|
423 |
|
---|
424 | # Generate scripts/pnglibconf.h
|
---|
425 | generate_source(OUTPUT "scripts/pnglibconf.c"
|
---|
426 | DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa"
|
---|
427 | "${CMAKE_CURRENT_BINARY_DIR}/scripts/options.awk"
|
---|
428 | "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h")
|
---|
429 | add_custom_target(png_scripts_pnglibconf_c
|
---|
430 | DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c")
|
---|
431 |
|
---|
432 | # Generate pnglibconf.c
|
---|
433 | generate_source(OUTPUT "pnglibconf.c"
|
---|
434 | DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa"
|
---|
435 | "${CMAKE_CURRENT_BINARY_DIR}/scripts/options.awk"
|
---|
436 | "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h")
|
---|
437 | add_custom_target(pnglibconf_c
|
---|
438 | DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c")
|
---|
439 |
|
---|
440 | if(PNG_PREFIX)
|
---|
441 | set(PNGLIBCONF_H_EXTRA_DEPENDS
|
---|
442 | "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
|
---|
443 | "${CMAKE_CURRENT_SOURCE_DIR}/scripts/macro.lst")
|
---|
444 | set(PNGPREFIX_H_EXTRA_DEPENDS
|
---|
445 | "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out")
|
---|
446 | endif()
|
---|
447 |
|
---|
448 | generate_out(INPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c"
|
---|
449 | OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out"
|
---|
450 | DEPENDS pnglibconf_c)
|
---|
451 | add_custom_target(pnglibconf_out
|
---|
452 | DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out")
|
---|
453 |
|
---|
454 | # Generate pnglibconf.h
|
---|
455 | generate_source(OUTPUT "pnglibconf.h"
|
---|
456 | DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" pnglibconf_out
|
---|
457 | ${PNGLIBCONF_H_EXTRA_DEPENDS})
|
---|
458 | add_custom_target(pnglibconf_h
|
---|
459 | DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
|
---|
460 |
|
---|
461 | generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/intprefix.c"
|
---|
462 | OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out"
|
---|
463 | DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" pnglibconf_h)
|
---|
464 | add_custom_target(png_scripts_intprefix_out
|
---|
465 | DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out")
|
---|
466 |
|
---|
467 | generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/prefix.c"
|
---|
468 | OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
|
---|
469 | DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
|
---|
470 | "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
|
---|
471 | "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" pnglibconf_out)
|
---|
472 | add_custom_target(png_scripts_prefix_out
|
---|
473 | DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out")
|
---|
474 |
|
---|
475 | # Generate pngprefix.h
|
---|
476 | generate_source(OUTPUT "pngprefix.h"
|
---|
477 | DEPENDS ${PNGPREFIX_H_EXTRA_DEPENDS})
|
---|
478 | add_custom_target(pngprefix_h
|
---|
479 | DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h")
|
---|
480 |
|
---|
481 | generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/sym.c"
|
---|
482 | OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
|
---|
483 | DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" pnglibconf_h)
|
---|
484 | add_custom_target(png_scripts_sym_out
|
---|
485 | DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out")
|
---|
486 |
|
---|
487 | generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.c"
|
---|
488 | OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
|
---|
489 | DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
|
---|
490 | "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
|
---|
491 | "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt")
|
---|
492 | add_custom_target(png_scripts_symbols_out
|
---|
493 | DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out")
|
---|
494 |
|
---|
495 | generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/vers.c"
|
---|
496 | OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out"
|
---|
497 | DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
|
---|
498 | "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
|
---|
499 | "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" pnglibconf_h)
|
---|
500 | add_custom_target(png_scripts_vers_out
|
---|
501 | DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out")
|
---|
502 |
|
---|
503 | generate_chk(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
|
---|
504 | OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk"
|
---|
505 | DEPENDS png_scripts_symbols_out
|
---|
506 | "${CMAKE_CURRENT_BINARY_DIR}/scripts/checksym.awk"
|
---|
507 | "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.def")
|
---|
508 |
|
---|
509 | add_custom_target(png_scripts_symbols_chk
|
---|
510 | DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk")
|
---|
511 |
|
---|
512 | generate_copy(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
|
---|
513 | OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym"
|
---|
514 | DEPENDS png_scripts_sym_out)
|
---|
515 | generate_copy(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out"
|
---|
516 | OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers"
|
---|
517 | DEPENDS png_scripts_vers_out)
|
---|
518 |
|
---|
519 | add_custom_target(png_genvers
|
---|
520 | DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers")
|
---|
521 | add_custom_target(png_gensym
|
---|
522 | DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym")
|
---|
523 |
|
---|
524 | add_custom_target(png_genprebuilt
|
---|
525 | COMMAND "${CMAKE_COMMAND}"
|
---|
526 | "-DOUTPUT=scripts/pnglibconf.h.prebuilt"
|
---|
527 | -P "${CMAKE_CURRENT_BINARY_DIR}/gensrc.cmake"
|
---|
528 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
---|
529 |
|
---|
530 | # A single target handles generation of all generated files.
|
---|
531 | add_custom_target(png_genfiles
|
---|
532 | DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym" png_gensym
|
---|
533 | "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers" png_genvers
|
---|
534 | "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c" pnglibconf_c
|
---|
535 | "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" pnglibconf_h
|
---|
536 | "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" pnglibconf_out
|
---|
537 | "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h" pngprefix_h
|
---|
538 | "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out" png_scripts_intprefix_out
|
---|
539 | "${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c" png_scripts_pnglibconf_c
|
---|
540 | "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" png_scripts_prefix_out
|
---|
541 | "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" png_scripts_sym_out
|
---|
542 | "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk" png_scripts_symbols_chk
|
---|
543 | "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" png_scripts_symbols_out
|
---|
544 | "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out" png_scripts_vers_out)
|
---|
545 | endif(NOT AWK OR ANDROID OR IOS)
|
---|
546 |
|
---|
547 | # List the source code files.
|
---|
548 | set(libpng_public_hdrs
|
---|
549 | png.h
|
---|
550 | pngconf.h
|
---|
551 | "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
|
---|
552 | )
|
---|
553 | set(libpng_private_hdrs
|
---|
554 | pngpriv.h
|
---|
555 | pngdebug.h
|
---|
556 | pnginfo.h
|
---|
557 | pngstruct.h
|
---|
558 | )
|
---|
559 | if(AWK AND NOT ANDROID AND NOT IOS)
|
---|
560 | list(APPEND libpng_private_hdrs "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h")
|
---|
561 | endif()
|
---|
562 | set(libpng_sources
|
---|
563 | ${libpng_public_hdrs}
|
---|
564 | ${libpng_private_hdrs}
|
---|
565 | png.c
|
---|
566 | pngerror.c
|
---|
567 | pngget.c
|
---|
568 | pngmem.c
|
---|
569 | pngpread.c
|
---|
570 | pngread.c
|
---|
571 | pngrio.c
|
---|
572 | pngrtran.c
|
---|
573 | pngrutil.c
|
---|
574 | pngset.c
|
---|
575 | pngtrans.c
|
---|
576 | pngwio.c
|
---|
577 | pngwrite.c
|
---|
578 | pngwtran.c
|
---|
579 | pngwutil.c
|
---|
580 | ${libpng_arm_sources}
|
---|
581 | ${libpng_intel_sources}
|
---|
582 | ${libpng_mips_sources}
|
---|
583 | ${libpng_powerpc_sources}
|
---|
584 | )
|
---|
585 | set(pngtest_sources
|
---|
586 | pngtest.c
|
---|
587 | )
|
---|
588 | set(pngvalid_sources
|
---|
589 | contrib/libtests/pngvalid.c
|
---|
590 | )
|
---|
591 | set(pngstest_sources
|
---|
592 | contrib/libtests/pngstest.c
|
---|
593 | )
|
---|
594 | set(pngunknown_sources
|
---|
595 | contrib/libtests/pngunknown.c
|
---|
596 | )
|
---|
597 | set(pngimage_sources
|
---|
598 | contrib/libtests/pngimage.c
|
---|
599 | )
|
---|
600 | set(pngfix_sources
|
---|
601 | contrib/tools/pngfix.c
|
---|
602 | )
|
---|
603 | set(png_fix_itxt_sources
|
---|
604 | contrib/tools/png-fix-itxt.c
|
---|
605 | )
|
---|
606 |
|
---|
607 | if(MSVC OR (WIN32 AND (CMAKE_C_COMPILER_ID MATCHES "Clang")))
|
---|
608 | add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
|
---|
609 | add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
---|
610 | endif()
|
---|
611 |
|
---|
612 | if(PNG_DEBUG)
|
---|
613 | add_definitions(-DPNG_DEBUG)
|
---|
614 | endif()
|
---|
615 |
|
---|
616 | # Now build our targets.
|
---|
617 |
|
---|
618 | # Initialize the list of libpng library targets.
|
---|
619 | set(PNG_LIBRARY_TARGETS "")
|
---|
620 |
|
---|
621 | # Initialize the libpng library file names.
|
---|
622 | if(UNIX
|
---|
623 | OR (WIN32 AND NOT CMAKE_SHARED_LIBRARY_PREFIX STREQUAL "")
|
---|
624 | OR (WIN32 AND NOT CMAKE_STATIC_LIBRARY_PREFIX STREQUAL ""))
|
---|
625 | # We are on a Unix or Unix-like toolchain like the GNU toolchain on Windows.
|
---|
626 | # Library file names are expected to have an implicit prefix such as "lib".
|
---|
627 | # Let CMake prepend and append its usual prefixes and suffixes by default.
|
---|
628 | set(PNG_SHARED_OUTPUT_NAME "png${PNGLIB_ABI_VERSION}")
|
---|
629 | set(PNG_STATIC_OUTPUT_NAME "png${PNGLIB_ABI_VERSION}")
|
---|
630 | else()
|
---|
631 | # We are, most likely, on a Windows toolchain like MSVC, Clang on Windows,
|
---|
632 | # Borland/Embarcadero, etc. We need to specify the "libpng" name explicitly.
|
---|
633 | # We also need to use a custom suffix, in order to distinguish between the
|
---|
634 | # shared import library name and the static library name.
|
---|
635 | set(PNG_SHARED_OUTPUT_NAME "libpng${PNGLIB_ABI_VERSION}")
|
---|
636 | set(PNG_STATIC_OUTPUT_NAME "libpng${PNGLIB_ABI_VERSION}_static")
|
---|
637 | endif()
|
---|
638 |
|
---|
639 | if(PNG_SHARED)
|
---|
640 | add_library(png_shared SHARED ${libpng_sources})
|
---|
641 | add_dependencies(png_shared png_genfiles)
|
---|
642 | list(APPEND PNG_LIBRARY_TARGETS png_shared)
|
---|
643 | set_target_properties(png_shared PROPERTIES
|
---|
644 | OUTPUT_NAME "${PNG_SHARED_OUTPUT_NAME}"
|
---|
645 | DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}"
|
---|
646 | VERSION "${PNGLIB_SHARED_VERSION}"
|
---|
647 | SOVERSION "${PNGLIB_ABI_VERSION}")
|
---|
648 | if(UNIX AND AWK)
|
---|
649 | if(HAVE_LD_VERSION_SCRIPT)
|
---|
650 | set_target_properties(png_shared PROPERTIES
|
---|
651 | LINK_FLAGS "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'")
|
---|
652 | elseif(HAVE_SOLARIS_LD_VERSION_SCRIPT)
|
---|
653 | set_target_properties(png_shared PROPERTIES
|
---|
654 | LINK_FLAGS "-Wl,-M -Wl,'${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'")
|
---|
655 | endif()
|
---|
656 | endif()
|
---|
657 | if(APPLE)
|
---|
658 | # Avoid CMake's implicit compile definition "png_shared_EXPORTS".
|
---|
659 | set_target_properties(png_shared PROPERTIES DEFINE_SYMBOL "")
|
---|
660 | elseif(WIN32)
|
---|
661 | # Use the explicit compile definition "PNG_BUILD_DLL" for Windows DLLs.
|
---|
662 | set_target_properties(png_shared PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
|
---|
663 | endif()
|
---|
664 | target_include_directories(png_shared
|
---|
665 | PUBLIC
|
---|
666 | $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>
|
---|
667 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
---|
668 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
---|
669 | target_link_libraries(png_shared PUBLIC ZLIB::ZLIB ${M_LIBRARY})
|
---|
670 | endif()
|
---|
671 |
|
---|
672 | if(PNG_STATIC)
|
---|
673 | add_library(png_static STATIC ${libpng_sources})
|
---|
674 | add_dependencies(png_static png_genfiles)
|
---|
675 | list(APPEND PNG_LIBRARY_TARGETS png_static)
|
---|
676 | set_target_properties(png_static PROPERTIES
|
---|
677 | OUTPUT_NAME "${PNG_STATIC_OUTPUT_NAME}"
|
---|
678 | DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}")
|
---|
679 | target_include_directories(png_static
|
---|
680 | PUBLIC
|
---|
681 | $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>
|
---|
682 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
---|
683 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
---|
684 | target_link_libraries(png_static PUBLIC ZLIB::ZLIB ${M_LIBRARY})
|
---|
685 | endif()
|
---|
686 |
|
---|
687 | if(PNG_FRAMEWORK AND APPLE)
|
---|
688 | add_library(png_framework SHARED ${libpng_sources})
|
---|
689 | add_dependencies(png_framework png_genfiles)
|
---|
690 | list(APPEND PNG_LIBRARY_TARGETS png_framework)
|
---|
691 | set_target_properties(png_framework PROPERTIES
|
---|
692 | FRAMEWORK TRUE
|
---|
693 | FRAMEWORK_VERSION "${PNGLIB_VERSION}"
|
---|
694 | MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${PNGLIB_MAJOR}.${PNGLIB_MINOR}"
|
---|
695 | MACOSX_FRAMEWORK_BUNDLE_VERSION "${PNGLIB_VERSION}"
|
---|
696 | MACOSX_FRAMEWORK_IDENTIFIER "org.libpng.libpng"
|
---|
697 | XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
|
---|
698 | PUBLIC_HEADER "${libpng_public_hdrs}"
|
---|
699 | OUTPUT_NAME "png"
|
---|
700 | DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}")
|
---|
701 | # Avoid CMake's implicit compile definition "-Dpng_framework_EXPORTS".
|
---|
702 | set_target_properties(png_framework PROPERTIES DEFINE_SYMBOL "")
|
---|
703 | target_include_directories(png_framework
|
---|
704 | PUBLIC
|
---|
705 | $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>
|
---|
706 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
---|
707 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
---|
708 | target_link_libraries(png_framework PUBLIC ZLIB::ZLIB ${M_LIBRARY})
|
---|
709 | endif()
|
---|
710 |
|
---|
711 | if(NOT PNG_LIBRARY_TARGETS)
|
---|
712 | message(SEND_ERROR "No library variant selected to build. "
|
---|
713 | "Please enable at least one of the following options: "
|
---|
714 | "PNG_SHARED, PNG_STATIC, PNG_FRAMEWORK")
|
---|
715 | endif()
|
---|
716 |
|
---|
717 | if(PNG_TESTS AND PNG_SHARED)
|
---|
718 | enable_testing()
|
---|
719 |
|
---|
720 | function(png_add_test)
|
---|
721 | set(options)
|
---|
722 | set(oneValueArgs NAME COMMAND)
|
---|
723 | set(multiValueArgs OPTIONS FILES)
|
---|
724 | cmake_parse_arguments(_PAT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
---|
725 | if(NOT _PAT_NAME)
|
---|
726 | message(FATAL_ERROR "png_add_test: Missing NAME argument")
|
---|
727 | endif()
|
---|
728 | if(NOT _PAT_COMMAND)
|
---|
729 | message(FATAL_ERROR "png_add_test: Missing COMMAND argument")
|
---|
730 | endif()
|
---|
731 |
|
---|
732 | set(TEST_OPTIONS "${_PAT_OPTIONS}")
|
---|
733 | set(TEST_FILES "${_PAT_FILES}")
|
---|
734 |
|
---|
735 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/test.cmake.in"
|
---|
736 | "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake"
|
---|
737 | @ONLY)
|
---|
738 | add_test(NAME "${_PAT_NAME}"
|
---|
739 | COMMAND "${CMAKE_COMMAND}"
|
---|
740 | "-DLIBPNG=$<TARGET_FILE:png_shared>"
|
---|
741 | "-DTEST_COMMAND=$<TARGET_FILE:${_PAT_COMMAND}>"
|
---|
742 | -P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake")
|
---|
743 | endfunction()
|
---|
744 |
|
---|
745 | # Find test PNG files by globbing, but sort lists to ensure
|
---|
746 | # consistency between different filesystems.
|
---|
747 | file(GLOB PNGSUITE_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/*.png")
|
---|
748 | list(SORT PNGSUITE_PNGS)
|
---|
749 | file(GLOB TEST_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/testpngs/*.png")
|
---|
750 | list(SORT TEST_PNGS)
|
---|
751 |
|
---|
752 | set(PNGTEST_PNG "${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png")
|
---|
753 |
|
---|
754 | add_executable(pngtest ${pngtest_sources})
|
---|
755 | target_link_libraries(pngtest PRIVATE png_shared)
|
---|
756 |
|
---|
757 | png_add_test(NAME pngtest
|
---|
758 | COMMAND pngtest
|
---|
759 | FILES "${PNGTEST_PNG}")
|
---|
760 |
|
---|
761 | add_executable(pngvalid ${pngvalid_sources})
|
---|
762 | target_link_libraries(pngvalid PRIVATE png_shared)
|
---|
763 |
|
---|
764 | png_add_test(NAME pngvalid-gamma-16-to-8
|
---|
765 | COMMAND pngvalid
|
---|
766 | OPTIONS --gamma-16-to-8)
|
---|
767 | png_add_test(NAME pngvalid-gamma-alpha-mode
|
---|
768 | COMMAND pngvalid
|
---|
769 | OPTIONS --gamma-alpha-mode)
|
---|
770 | png_add_test(NAME pngvalid-gamma-background
|
---|
771 | COMMAND pngvalid
|
---|
772 | OPTIONS --gamma-background)
|
---|
773 | png_add_test(NAME pngvalid-gamma-expand16-alpha-mode
|
---|
774 | COMMAND pngvalid
|
---|
775 | OPTIONS --gamma-alpha-mode --expand16)
|
---|
776 | png_add_test(NAME pngvalid-gamma-expand16-background
|
---|
777 | COMMAND pngvalid
|
---|
778 | OPTIONS --gamma-background --expand16)
|
---|
779 | png_add_test(NAME pngvalid-gamma-expand16-transform
|
---|
780 | COMMAND pngvalid
|
---|
781 | OPTIONS --gamma-transform --expand16)
|
---|
782 | png_add_test(NAME pngvalid-gamma-sbit
|
---|
783 | COMMAND pngvalid
|
---|
784 | OPTIONS --gamma-sbit)
|
---|
785 | png_add_test(NAME pngvalid-gamma-threshold
|
---|
786 | COMMAND pngvalid
|
---|
787 | OPTIONS --gamma-threshold)
|
---|
788 | png_add_test(NAME pngvalid-gamma-transform
|
---|
789 | COMMAND pngvalid
|
---|
790 | OPTIONS --gamma-transform)
|
---|
791 | png_add_test(NAME pngvalid-progressive-interlace-standard
|
---|
792 | COMMAND pngvalid
|
---|
793 | OPTIONS --standard --progressive-read --interlace)
|
---|
794 | png_add_test(NAME pngvalid-progressive-size
|
---|
795 | COMMAND pngvalid
|
---|
796 | OPTIONS --size --progressive-read)
|
---|
797 | png_add_test(NAME pngvalid-progressive-standard
|
---|
798 | COMMAND pngvalid
|
---|
799 | OPTIONS --standard --progressive-read)
|
---|
800 | png_add_test(NAME pngvalid-standard
|
---|
801 | COMMAND pngvalid
|
---|
802 | OPTIONS --standard)
|
---|
803 | png_add_test(NAME pngvalid-transform
|
---|
804 | COMMAND pngvalid
|
---|
805 | OPTIONS --transform)
|
---|
806 |
|
---|
807 | add_executable(pngstest ${pngstest_sources})
|
---|
808 | target_link_libraries(pngstest PRIVATE png_shared)
|
---|
809 |
|
---|
810 | foreach(gamma_type 1.8 linear none sRGB)
|
---|
811 | foreach(alpha_type none alpha)
|
---|
812 | set(PNGSTEST_FILES)
|
---|
813 | foreach(test_png ${TEST_PNGS})
|
---|
814 | string(REGEX MATCH "-linear[-.]" TEST_PNG_LINEAR "${test_png}")
|
---|
815 | string(REGEX MATCH "-sRGB[-.]" TEST_PNG_SRGB "${test_png}")
|
---|
816 | string(REGEX MATCH "-1.8[-.]" TEST_PNG_G18 "${test_png}")
|
---|
817 | string(REGEX MATCH "-alpha-" TEST_PNG_ALPHA "${test_png}")
|
---|
818 |
|
---|
819 | set(TEST_PNG_VALID TRUE)
|
---|
820 |
|
---|
821 | if(TEST_PNG_ALPHA)
|
---|
822 | if(NOT alpha_type STREQUAL "alpha")
|
---|
823 | set(TEST_PNG_VALID FALSE)
|
---|
824 | endif()
|
---|
825 | else()
|
---|
826 | if(alpha_type STREQUAL "alpha")
|
---|
827 | set(TEST_PNG_VALID FALSE)
|
---|
828 | endif()
|
---|
829 | endif()
|
---|
830 |
|
---|
831 | if(TEST_PNG_LINEAR)
|
---|
832 | if(NOT gamma_type STREQUAL "linear")
|
---|
833 | set(TEST_PNG_VALID FALSE)
|
---|
834 | endif()
|
---|
835 | elseif(TEST_PNG_SRGB)
|
---|
836 | if(NOT gamma_type STREQUAL "sRGB")
|
---|
837 | set(TEST_PNG_VALID FALSE)
|
---|
838 | endif()
|
---|
839 | elseif(TEST_PNG_G18)
|
---|
840 | if(NOT gamma_type STREQUAL "1.8")
|
---|
841 | set(TEST_PNG_VALID FALSE)
|
---|
842 | endif()
|
---|
843 | else()
|
---|
844 | if(NOT gamma_type STREQUAL "none")
|
---|
845 | set(TEST_PNG_VALID FALSE)
|
---|
846 | endif()
|
---|
847 | endif()
|
---|
848 |
|
---|
849 | if(TEST_PNG_VALID)
|
---|
850 | list(APPEND PNGSTEST_FILES "${test_png}")
|
---|
851 | endif()
|
---|
852 | endforeach()
|
---|
853 | # Should already be sorted, but sort anyway to be certain.
|
---|
854 | list(SORT PNGSTEST_FILES)
|
---|
855 | png_add_test(NAME pngstest-${gamma_type}-${alpha_type}
|
---|
856 | COMMAND pngstest
|
---|
857 | OPTIONS --tmpfile "${gamma_type}-${alpha_type}-" --log
|
---|
858 | FILES ${PNGSTEST_FILES})
|
---|
859 | endforeach()
|
---|
860 | endforeach()
|
---|
861 |
|
---|
862 | add_executable(pngunknown ${pngunknown_sources})
|
---|
863 | target_link_libraries(pngunknown PRIVATE png_shared)
|
---|
864 |
|
---|
865 | png_add_test(NAME pngunknown-discard
|
---|
866 | COMMAND pngunknown
|
---|
867 | OPTIONS --strict default=discard
|
---|
868 | FILES "${PNGTEST_PNG}")
|
---|
869 | png_add_test(NAME pngunknown-IDAT
|
---|
870 | COMMAND pngunknown
|
---|
871 | OPTIONS --strict default=discard IDAT=save
|
---|
872 | FILES "${PNGTEST_PNG}")
|
---|
873 | png_add_test(NAME pngunknown-if-safe
|
---|
874 | COMMAND pngunknown
|
---|
875 | OPTIONS --strict default=if-safe
|
---|
876 | FILES "${PNGTEST_PNG}")
|
---|
877 | png_add_test(NAME pngunknown-sAPI
|
---|
878 | COMMAND pngunknown
|
---|
879 | OPTIONS --strict bKGD=save cHRM=save gAMA=save all=discard iCCP=save sBIT=save sRGB=save
|
---|
880 | FILES "${PNGTEST_PNG}")
|
---|
881 | png_add_test(NAME pngunknown-save
|
---|
882 | COMMAND pngunknown
|
---|
883 | OPTIONS --strict default=save
|
---|
884 | FILES "${PNGTEST_PNG}")
|
---|
885 | png_add_test(NAME pngunknown-sTER
|
---|
886 | COMMAND pngunknown
|
---|
887 | OPTIONS --strict sTER=if-safe
|
---|
888 | FILES "${PNGTEST_PNG}")
|
---|
889 | png_add_test(NAME pngunknown-vpAg
|
---|
890 | COMMAND pngunknown
|
---|
891 | OPTIONS --strict vpAg=if-safe
|
---|
892 | FILES "${PNGTEST_PNG}")
|
---|
893 |
|
---|
894 | add_executable(pngimage ${pngimage_sources})
|
---|
895 | target_link_libraries(pngimage PRIVATE png_shared)
|
---|
896 |
|
---|
897 | png_add_test(NAME pngimage-quick
|
---|
898 | COMMAND pngimage
|
---|
899 | OPTIONS --list-combos --log
|
---|
900 | FILES ${PNGSUITE_PNGS})
|
---|
901 | png_add_test(NAME pngimage-full
|
---|
902 | COMMAND pngimage
|
---|
903 | OPTIONS --exhaustive --list-combos --log
|
---|
904 | FILES ${PNGSUITE_PNGS})
|
---|
905 | endif()
|
---|
906 |
|
---|
907 | if(PNG_SHARED AND PNG_TOOLS)
|
---|
908 | add_executable(pngfix ${pngfix_sources})
|
---|
909 | target_link_libraries(pngfix PRIVATE png_shared)
|
---|
910 | set(PNG_BIN_TARGETS pngfix)
|
---|
911 |
|
---|
912 | add_executable(png-fix-itxt ${png_fix_itxt_sources})
|
---|
913 | target_link_libraries(png-fix-itxt PRIVATE ZLIB::ZLIB ${M_LIBRARY})
|
---|
914 | list(APPEND PNG_BIN_TARGETS png-fix-itxt)
|
---|
915 | endif()
|
---|
916 |
|
---|
917 | # Create a symlink from src to dest (if possible), or, alternatively,
|
---|
918 | # copy src to dest if different.
|
---|
919 | function(create_symlink DEST_FILE)
|
---|
920 | cmake_parse_arguments(_SYM "" "FILE;TARGET" "" ${ARGN})
|
---|
921 | if(NOT _SYM_FILE AND NOT _SYM_TARGET)
|
---|
922 | message(FATAL_ERROR "create_symlink: Missing FILE or TARGET argument")
|
---|
923 | endif()
|
---|
924 | if(_SYM_FILE AND _SYM_TARGET)
|
---|
925 | message(FATAL_ERROR "create_symlink: "
|
---|
926 | "The arguments FILE (${_SYM_FILE}) and TARGET (${_SYM_TARGET}) "
|
---|
927 | "are mutually-exclusive")
|
---|
928 | endif()
|
---|
929 |
|
---|
930 | if(_SYM_FILE)
|
---|
931 | # If we don't need to symlink something that's coming from a build target,
|
---|
932 | # we can go ahead and symlink/copy at configure time.
|
---|
933 | if(CMAKE_HOST_WIN32 AND NOT CYGWIN)
|
---|
934 | execute_process(COMMAND "${CMAKE_COMMAND}"
|
---|
935 | -E copy_if_different
|
---|
936 | ${_SYM_FILE} ${DEST_FILE}
|
---|
937 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
---|
938 | else()
|
---|
939 | execute_process(COMMAND "${CMAKE_COMMAND}"
|
---|
940 | -E create_symlink
|
---|
941 | ${_SYM_FILE} ${DEST_FILE}
|
---|
942 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
---|
943 | endif()
|
---|
944 | endif()
|
---|
945 |
|
---|
946 | if(_SYM_TARGET)
|
---|
947 | # We need to use generator expressions, which can be a bit tricky.
|
---|
948 | # For simplicity, make the symlink a POST_BUILD step, and use the TARGET
|
---|
949 | # signature of add_custom_command.
|
---|
950 | if(CMAKE_HOST_WIN32 AND NOT CYGWIN)
|
---|
951 | add_custom_command(TARGET ${_SYM_TARGET}
|
---|
952 | POST_BUILD
|
---|
953 | COMMAND "${CMAKE_COMMAND}"
|
---|
954 | -E copy_if_different
|
---|
955 | $<TARGET_LINKER_FILE_DIR:${_SYM_TARGET}>/$<TARGET_LINKER_FILE_NAME:${_SYM_TARGET}>
|
---|
956 | $<TARGET_LINKER_FILE_DIR:${_SYM_TARGET}>/${DEST_FILE})
|
---|
957 | else()
|
---|
958 | add_custom_command(TARGET ${_SYM_TARGET}
|
---|
959 | POST_BUILD
|
---|
960 | COMMAND "${CMAKE_COMMAND}"
|
---|
961 | -E create_symlink
|
---|
962 | $<TARGET_LINKER_FILE_NAME:${_SYM_TARGET}>
|
---|
963 | $<TARGET_LINKER_FILE_DIR:${_SYM_TARGET}>/${DEST_FILE})
|
---|
964 | endif()
|
---|
965 | endif()
|
---|
966 | endfunction()
|
---|
967 |
|
---|
968 | # Create source generation scripts.
|
---|
969 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/genchk.cmake.in
|
---|
970 | ${CMAKE_CURRENT_BINARY_DIR}/genchk.cmake
|
---|
971 | @ONLY)
|
---|
972 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/genout.cmake.in
|
---|
973 | ${CMAKE_CURRENT_BINARY_DIR}/genout.cmake
|
---|
974 | @ONLY)
|
---|
975 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/gensrc.cmake.in
|
---|
976 | ${CMAKE_CURRENT_BINARY_DIR}/gensrc.cmake
|
---|
977 | @ONLY)
|
---|
978 |
|
---|
979 | # libpng is a library so default to 'lib'
|
---|
980 | if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
---|
981 | set(CMAKE_INSTALL_LIBDIR lib)
|
---|
982 | endif()
|
---|
983 |
|
---|
984 | # Create pkgconfig files.
|
---|
985 | # We use the same files like ./configure, so we have to set its vars.
|
---|
986 | # Only do this on Windows for Cygwin - the files don't make much sense
|
---|
987 | # outside of a UNIX look-alike.
|
---|
988 | if(NOT WIN32 OR CYGWIN OR MINGW)
|
---|
989 | set(prefix ${CMAKE_INSTALL_PREFIX})
|
---|
990 | set(exec_prefix ${CMAKE_INSTALL_PREFIX})
|
---|
991 | set(libdir ${CMAKE_INSTALL_FULL_LIBDIR})
|
---|
992 | set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR})
|
---|
993 | set(LIBS "-lz -lm")
|
---|
994 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in
|
---|
995 | ${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}.pc
|
---|
996 | @ONLY)
|
---|
997 | create_symlink(libpng.pc FILE libpng${PNGLIB_ABI_VERSION}.pc)
|
---|
998 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in
|
---|
999 | ${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}-config
|
---|
1000 | @ONLY)
|
---|
1001 | create_symlink(libpng-config FILE libpng${PNGLIB_ABI_VERSION}-config)
|
---|
1002 | endif()
|
---|
1003 |
|
---|
1004 | # Install.
|
---|
1005 | if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
|
---|
1006 | install(TARGETS ${PNG_LIBRARY_TARGETS}
|
---|
1007 | EXPORT libpng
|
---|
1008 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
---|
1009 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
---|
1010 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
---|
1011 | FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
---|
1012 |
|
---|
1013 | if(PNG_SHARED)
|
---|
1014 | # Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin
|
---|
1015 | if(NOT WIN32 OR CYGWIN OR MINGW)
|
---|
1016 | create_symlink(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png_shared)
|
---|
1017 | install(FILES $<TARGET_LINKER_FILE_DIR:png_shared>/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
|
---|
1018 | DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
---|
1019 | endif()
|
---|
1020 | endif()
|
---|
1021 |
|
---|
1022 | if(PNG_STATIC)
|
---|
1023 | if(NOT WIN32 OR CYGWIN OR MINGW)
|
---|
1024 | create_symlink(libpng${CMAKE_STATIC_LIBRARY_SUFFIX} TARGET png_static)
|
---|
1025 | install(FILES $<TARGET_LINKER_FILE_DIR:png_static>/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
|
---|
1026 | DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
---|
1027 | endif()
|
---|
1028 | endif()
|
---|
1029 | endif()
|
---|
1030 |
|
---|
1031 | if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL)
|
---|
1032 | install(FILES ${libpng_public_hdrs}
|
---|
1033 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
---|
1034 | install(FILES ${libpng_public_hdrs}
|
---|
1035 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION})
|
---|
1036 | endif()
|
---|
1037 | if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL)
|
---|
1038 | if(NOT WIN32 OR CYGWIN OR MINGW)
|
---|
1039 | install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config
|
---|
1040 | DESTINATION ${CMAKE_INSTALL_BINDIR})
|
---|
1041 | install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}-config
|
---|
1042 | DESTINATION ${CMAKE_INSTALL_BINDIR})
|
---|
1043 | endif()
|
---|
1044 | endif()
|
---|
1045 |
|
---|
1046 | if(NOT SKIP_INSTALL_PROGRAMS AND NOT SKIP_INSTALL_ALL)
|
---|
1047 | install(TARGETS ${PNG_BIN_TARGETS}
|
---|
1048 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
---|
1049 | endif()
|
---|
1050 |
|
---|
1051 | if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL)
|
---|
1052 | # Install the man pages.
|
---|
1053 | install(FILES libpng.3 libpngpf.3
|
---|
1054 | DESTINATION ${CMAKE_INSTALL_MANDIR}/man3)
|
---|
1055 | install(FILES png.5
|
---|
1056 | DESTINATION ${CMAKE_INSTALL_MANDIR}/man5)
|
---|
1057 | # Install the pkg-config files.
|
---|
1058 | if(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW)
|
---|
1059 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc
|
---|
1060 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
---|
1061 | install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config
|
---|
1062 | DESTINATION ${CMAKE_INSTALL_BINDIR})
|
---|
1063 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}.pc
|
---|
1064 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
---|
1065 | install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}-config
|
---|
1066 | DESTINATION ${CMAKE_INSTALL_BINDIR})
|
---|
1067 | endif()
|
---|
1068 | endif()
|
---|
1069 |
|
---|
1070 | # Create an export file that CMake users can include() to import our targets.
|
---|
1071 | if(NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL)
|
---|
1072 | install(EXPORT libpng
|
---|
1073 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/libpng
|
---|
1074 | FILE libpng${PNGLIB_ABI_VERSION}.cmake)
|
---|
1075 | endif()
|
---|
1076 |
|
---|
1077 | # TODO: Create MSVC import lib for MinGW-compiled shared lib.
|
---|
1078 | # pexports libpng.dll > libpng.def
|
---|
1079 | # lib /def:libpng.def /machine:x86
|
---|