File: gengetopt.cmake

package info (click to toggle)
yubihsm-shell 2.7.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,020 kB
  • sloc: ansic: 41,745; sh: 2,030; cpp: 528; makefile: 18; xml: 16
file content (31 lines) | stat: -rw-r--r-- 861 bytes parent folder | download | duplicates (3)
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
macro (find_gengetopt)
  if (NOT GENGETOPT_EXECUTABLE)
    find_program (GENGETOPT_EXECUTABLE gengetopt)
    if (NOT GENGETOPT_EXECUTABLE)
      message (FATAL_ERROR "gengetopt not found. Aborting...")
    endif ()
  endif ()
endmacro ()

macro (add_gengetopt_files _basename)
  find_gengetopt ()

  set (_ggo_extra_input ${ARGV})

  set (_ggo_c ${CMAKE_CURRENT_SOURCE_DIR}/${_basename}.c)
  set (_ggo_h ${CMAKE_CURRENT_SOURCE_DIR}/${_basename}.h)
  set (_ggo_g ${CMAKE_CURRENT_SOURCE_DIR}/${_basename}.ggo)

  add_custom_command (
    OUTPUT ${_ggo_c} ${_ggo_h}
    COMMAND gengetopt ${_ggo_extra_input} -i ${_ggo_g} --output-dir ${CMAKE_CURRENT_SOURCE_DIR}
    DEPENDS ${_ggo_g}
#    BYPRODUCTS
    COMMENT "Generating getopt parser code (cmdline.{h,c}) ..."
    VERBATIM
    )

  set (GGO_C ${_ggo_c})
  set (GGO_H ${_ggo_h})

endmacro (add_gengetopt_files)