File: PNGGenConfig.cmake

package info (click to toggle)
libpng1.6 1.6.55-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,208 kB
  • sloc: ansic: 58,258; sh: 6,981; awk: 794; cpp: 684; makefile: 617; python: 391; asm: 22
file content (104 lines) | stat: -rw-r--r-- 4,201 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# PNGGenConfig.cmake
# Utility functions for configuring and building libpng

# Copyright (c) 2018-2025 Cosmin Truta
# Copyright (c) 2016-2018 Glenn Randers-Pehrson
# Written by Roger Leigh, 2016
#
# Use, modification and distribution are subject to
# the same licensing terms and conditions as libpng.
# Please see the copyright notice in png.h or visit
# http://libpng.org/pub/png/src/libpng-LICENSE.txt
#
# SPDX-License-Identifier: libpng-2.0

# Generate .chk from .out with awk, based upon the automake logic:
# generate_chk(INPUT <file> OUTPUT <file> [DEPENDS <deps>...])
function(generate_chk)
  set(options)
  set(oneValueArgs INPUT OUTPUT)
  set(multiValueArgs DEPENDS)
  cmake_parse_arguments(_GENCHK "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
  if(NOT _GENCHK_INPUT)
    message(FATAL_ERROR "generate_chk: Missing INPUT argument")
  endif()
  if(NOT _GENCHK_OUTPUT)
    message(FATAL_ERROR "generate_chk: Missing OUTPUT argument")
  endif()

  # Run genchk.cmake to generate the .chk file.
  add_custom_command(OUTPUT "${_GENCHK_OUTPUT}"
                     COMMAND "${CMAKE_COMMAND}"
                             "-DINPUT=${_GENCHK_INPUT}"
                             "-DOUTPUT=${_GENCHK_OUTPUT}"
                             -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/genchk.cmake"
                     DEPENDS "${_GENCHK_INPUT}" ${_GENCHK_DEPENDS}
                     WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()

# Generate .out from C source file with awk:
# generate_out(INPUT <file> OUTPUT <file> [DEPENDS <deps>...])
function(generate_out)
  set(options)
  set(oneValueArgs INPUT OUTPUT)
  set(multiValueArgs DEPENDS)
  cmake_parse_arguments(_GENOUT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
  if(NOT _GENOUT_INPUT)
    message(FATAL_ERROR "generate_out: Missing INPUT argument")
  endif()
  if(NOT _GENOUT_OUTPUT)
    message(FATAL_ERROR "generate_out: Missing OUTPUT argument")
  endif()

  # Run genout.cmake to generate the .out file.
  add_custom_command(OUTPUT "${_GENOUT_OUTPUT}"
                     COMMAND "${CMAKE_COMMAND}"
                             "-DINPUT=${_GENOUT_INPUT}"
                             "-DOUTPUT=${_GENOUT_OUTPUT}"
                             -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/genout.cmake"
                     DEPENDS "${_GENOUT_INPUT}" ${_GENOUT_DEPENDS}
                     WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()

# Generate a source file with awk:
# generate_source(OUTPUT <file> [DEPENDS <deps>...])
function(generate_source)
  set(options)
  set(oneValueArgs OUTPUT)
  set(multiValueArgs DEPENDS)
  cmake_parse_arguments(_GENSRC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
  if(NOT _GENSRC_OUTPUT)
    message(FATAL_ERROR "generate_source: Missing OUTPUT argument")
  endif()

  # Run gensrc.cmake to generate the source file.
  add_custom_command(OUTPUT "${_GENSRC_OUTPUT}"
                     COMMAND "${CMAKE_COMMAND}"
                             "-DOUTPUT=${_GENSRC_OUTPUT}"
                             -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/gensrc.cmake"
                     DEPENDS ${_GENSRC_DEPENDS}
                     WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()

# Generate an identical file copy:
# generate_copy(INPUT <file> OUTPUT <file> [DEPENDS <deps>...])
function(generate_copy)
  set(options)
  set(oneValueArgs INPUT OUTPUT)
  set(multiValueArgs DEPENDS)
  cmake_parse_arguments(_GENCPY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
  if(NOT _GENCPY_INPUT)
    message(FATAL_ERROR "generate_copy: Missing INPUT argument")
  endif()
  if(NOT _GENCPY_OUTPUT)
    message(FATAL_ERROR "generate_copy: Missing OUTPUT argument")
  endif()

  # Make a forced file copy, overwriting any pre-existing output file.
  add_custom_command(OUTPUT "${_GENCPY_OUTPUT}"
                     COMMAND "${CMAKE_COMMAND}"
                             -E remove "${_GENCPY_OUTPUT}"
                     COMMAND "${CMAKE_COMMAND}"
                             -E copy "${_GENCPY_INPUT}" "${_GENCPY_OUTPUT}"
                     DEPENDS "${_GENCPY_INPUT}" ${_GENCPY_DEPENDS})
endfunction()