File: add_check_executable.cmake

package info (click to toggle)
cppad 2026.00.00.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,584 kB
  • sloc: cpp: 112,960; sh: 6,146; ansic: 179; python: 71; sed: 12; makefile: 10
file content (94 lines) | stat: -rw-r--r-- 3,380 bytes parent folder | download | duplicates (2)
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
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
# SPDX-FileCopyrightText: Bradley M. Bell <bradbell@seanet.com>
# SPDX-FileContributor: 2003-24 Bradley M. Bell
# ----------------------------------------------------------------------------
# add_check_executable(parent_target short_name)
# add_check_executable(parent_target short_name arguments)
#
# parent_target: (in)
# The variable containing the name of the parent check target,
# ${parent_target} must begin with "check".
#
# short_name: (in)
# Is the non-empty short name of the target we are adding.
# The full name of this target is ${parent_target}_${short_name}.
#
# arguments: (in)
# This argument is optional. If it is present, it is
# a string containing the arguments to the executable.
#
# 1. This macro creates the target ${parent_target}_${short_name}.
# 2. This target depends on an executable with the same name except that
#    the "check_" at the beginning is removed.
# 3. If the variable ${parent_target}_${short_name}_depends is defined,
#    it is a list that is included in the dependencies for this target.
# 4. This target is add to the list ${parent_target}_depends in both
#    the current scope and its parent scope.
#
# This macros uses temporary variables with names that begin with
# add_check_executable_.
#
MACRO(add_check_executable parent_target short_name)
   IF( NOT ${parent_target} MATCHES "^check" )
      MESSAGE(FATAL_ERROR "add_check_executable: "
         "parent_target does not begin with 'check'"
      )
   ENDIF( )
   IF( "${short_name}" STREQUAL "" )
      MESSAGE(FATAL_ERROR "add_check_target: short_name is empty")
   ENDIF( )
   #
   # add_check_executable_full_name
   SET(add_check_executable_full_name "${parent_target}_${short_name}" )
   #
   # add_check_executable_no_check
   STRING(REGEX REPLACE "^check_" "" add_check_executable_no_check
      "${add_check_executable_full_name}"
   )
   #
   # add_check_executable_arguments
   IF( ${ARGC} EQUAL 2 )
      SET(add_check_executable_arguments "")
   ELSEIF( ${ARGC} EQUAL 3 )
      STRING(
         REGEX REPLACE "[ ]" ";" add_check_executable_arguments "${ARGV2}"
      )
   ELSE( )
      MESSAGE(FATAL_ERROR "add_check_executable: "
         "number of arguments = ${ARGC}"
      )
   ENDIF( )
   #
   # add_check_executable_depends
   IF( DEFINED ${add_check_executable_full_name}_depends )
      SET(add_check_executable_depends
         ${${add_check_executable_full_name}_depends}
      )
      add_to_list(add_check_executable_depends
         ${add_check_executable_no_check}
      )
   ELSE ( )
      SET(add_check_executable_depends ${add_check_executable_no_check} )
   ENDIF( )
   #
   # create this target
   ADD_CUSTOM_TARGET(
      ${add_check_executable_full_name}
      ${add_check_executable_no_check}
      ${add_check_executable_arguments}
      DEPENDS ${add_check_executable_depends}
   )
   IF( "${CMAKE_GENERATOR}" STREQUAL "Ninja" )
      SET(make_cmd "ninja" )
   ELSEIF( "${CMAKE_GENERATOR}" STREQUAL "NMake Makefiles" )
      SET(make_cmd "nmake" )
   ELSE( )
      SET(make_cmd "make" )
   ENDIF( )
   MESSAGE(STATUS "${make_cmd} ${add_check_executable_full_name}: available")
   #
   # add parent dependency
   add_to_list( ${parent_target}_depends ${add_check_executable_full_name} )
   SET( ${parent_target}_depends ${${parent_target}_depends} PARENT_SCOPE )
   #
ENDMACRO()