File: set_compile_flags.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 (72 lines) | stat: -rw-r--r-- 2,716 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
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
# SPDX-FileCopyrightText: Bradley M. Bell <bradbell@seanet.com>
# SPDX-FileContributor: 2003-22 Bradley M. Bell
# ----------------------------------------------------------------------------
# set_compile_flags( program_name debug_which source_list)
#
# program_name: (in)
# Is the name of the program that we are building. This is only used
# for debugging which files have debug and which have release properties.
#
# debug_which: (in)
# Is one of the following cases:
#
# Case debug_even:
# The files with an even (odd) index in source_list have debug (release) flags.
#
# Case debug_odd:
# The files with an odd (even) index in source_list have debug (release) flags.
#
# Case debug_all, debug_none, or empty string:
# The debug and release flags are not set by this routine.
#
# source_list: (in)
# is a list of source files that get set to have debug or release
# compile flags. The cppad_cxx_flags compile flags always get included.
#
FUNCTION(set_compile_flags program_name debug_which source_list)
   # debug compile flags
   SET(debug_flags "${cppad_cxx_flags} ${CMAKE_CXX_FLAGS_DEBUG}")
   # release compile flags
   SET(release_flags "${cppad_cxx_flags} ${CMAKE_CXX_FLAGS_RELEASE}")
   #
   # set alternate, report random number result,
   # set compile flags property when not alternating.
   IF( "${debug_which}" STREQUAL "debug_even" )
      SET(alternate TRUE)
      SET(count_mod_2 0)
   ELSEIF( "${debug_which}" STREQUAL "debug_odd" )
      SET(alternate TRUE)
      SET(count_mod_2 1)
   ELSE( "${debug_which}" )
      SET(alternate FALSE)
      IF( NOT "${cppad_cxx_flags}" STREQUAL "" )
         SET(alternate FALSE)
         SET_SOURCE_FILES_PROPERTIES(
            ${source_list} PROPERTIES COMPILE_FLAGS "${cppad_cxx_flags}"
         )
      ENDIF( NOT "${cppad_cxx_flags}" STREQUAL "" )
   ENDIF( "${debug_which}" STREQUAL "debug_even" )
   #
   IF( alternate )
      SET(debug_list   "")
      SET(release_list "")
      FOREACH(source ${source_list})
         MATH(EXPR count_mod_2 "(${count_mod_2} + 1) % 2")
         IF( count_mod_2 )
            add_to_list(debug_list ${source})
         ELSE( count_mod_2 )
            add_to_list(release_list ${source})
         ENDIF( count_mod_2 )
      ENDFOREACH(source ${source_list})
      SET_SOURCE_FILES_PROPERTIES(
         ${debug_list} PROPERTIES COMPILE_FLAGS "${debug_flags}"
      )
      SET_SOURCE_FILES_PROPERTIES(
         ${release_list} PROPERTIES COMPILE_FLAGS "${release_flags}"
      )
      # IF( ${program_name} STREQUAL "..." )
      #   print_variable( ... )
      # ENDIF( )
   ENDIF( alternate )
ENDFUNCTION(set_compile_flags program_name debug_which source_list)