debug_rel branch:
Change random_debug_release -> set_compile_flags.
Brad Bell
6 years ago
69 | 69 | # print_variable(variable) |
70 | 70 | INCLUDE(cmake/print_variable.cmake) |
71 | 71 | # |
72 | # random_debug_release(program_name source_list) | |
73 | INCLUDE(cmake/random_debug_release.cmake) | |
72 | # set_compile_flags( program_name debug_which source_list) | |
73 | INCLUDE(cmake/set_compile_flags.cmake) | |
74 | 74 | # ============================================================================= |
75 | 75 | # command line arguments |
76 | 76 | # ============================================================================= |
188 | 188 | # ============================================================================= |
189 | 189 | # Make a random choice from the set {0, 1, 2, 3} |
190 | 190 | STRING(RANDOM LENGTH 1 ALPHABET 0123 random_choice_in_0123) |
191 | print_variable(random_choice_in_0123) | |
191 | IF( "${random_choice_in_0123}" STREQUAL "0" ) | |
192 | SET(cppad_debug_which "debug_even") | |
193 | ELSEIF( "${random_choice_in_0123}" STREQUAL "1" ) | |
194 | SET(cppad_debug_which "debug_odd") | |
195 | ELSEIF( "${random_choice_in_0123}" STREQUAL "2" ) | |
196 | SET(cppad_debug_which "debug_all") | |
197 | ELSE( "${random_choice_in_0123}" STREQUAL "3" ) | |
198 | SET(cppad_debug_which "debug_none") | |
199 | ENDIF( "${random_choice_in_0123}" STREQUAL "0" ) | |
200 | print_variable(cppad_debug_which) | |
192 | 201 | # ============================================================================= |
193 | 202 | # cppad_has_colpack, colpack_libs, cppad_lib |
194 | 203 | # |
0 | # ----------------------------------------------------------------------------- | |
1 | # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell | |
2 | # | |
3 | # CppAD is distributed under multiple licenses. This distribution is under | |
4 | # the terms of the | |
5 | # Eclipse Public License Version 1.0. | |
6 | # | |
7 | # A copy of this license is included in the COPYING file of this distribution. | |
8 | # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. | |
9 | # ----------------------------------------------------------------------------- | |
10 | # random_debug_release(program_name source_list) | |
11 | # | |
12 | # program_name: (in) | |
13 | # Is the name of the program that we are building. This is only used to | |
14 | # report which files have debug and which have release properties. | |
15 | # | |
16 | # source_list: (in) | |
17 | # is a list of source files that randomly get set to have debug or release | |
18 | # compile flags. The cppad_cxx_flags compile flags always get included. | |
19 | # | |
20 | # Case ${random_choice_in_0123} = 0: | |
21 | # The files with an even (odd) index in source_list have debug (release) flags. | |
22 | # In addition the compiler flag -DCPPAD_DEBUG_AND_RELEASE is added. | |
23 | # | |
24 | # Case ${random_choice_in_0123} = 1: | |
25 | # The files with an odd (even) index in source_list have debug (release) flags. | |
26 | # In addition the compiler flag -DCPPAD_DEBUG_AND_RELEASE is added. | |
27 | # | |
28 | # Case ${random_choice_in_0123} = 2: | |
29 | # All the files have debug flags. | |
30 | # | |
31 | # Case ${random_choice_in_0123} = 3: | |
32 | # All the the files have release flags. | |
33 | # | |
34 | FUNCTION(random_debug_release program_name source_list) | |
35 | # debug compile flags | |
36 | SET(debug_flags "${cppad_cxx_flags} ${CMAKE_CXX_FLAGS_DEBUG}") | |
37 | # relese compile flags | |
38 | SET(release_flags "${cppad_cxx_flags} ${CMAKE_CXX_FLAGS_RELEASE}") | |
39 | # | |
40 | # set alternate, report random number result, | |
41 | # set compile flags property when not alternating. | |
42 | IF( ${random_choice_in_0123} STREQUAL 0 ) | |
43 | SET(alternate TRUE) | |
44 | ELSEIF( ${random_choice_in_0123} STREQUAL 1 ) | |
45 | SET(alternate TRUE) | |
46 | ELSEIF( ${random_choice_in_0123} STREQUAL 2 ) | |
47 | SET(alternate FALSE) | |
48 | SET_SOURCE_FILES_PROPERTIES( | |
49 | ${source_list} PROPERTIES COMPILE_FLAGS "${debug_flags}" | |
50 | ) | |
51 | ELSEIF( ${random_choice_in_0123} STREQUAL 3 ) | |
52 | SET(alternate FALSE) | |
53 | SET_SOURCE_FILES_PROPERTIES( | |
54 | ${source_list} PROPERTIES COMPILE_FLAGS "${release_flags}" | |
55 | ) | |
56 | ELSE( ${random_choice_in_0123} STREQUAL 4 ) | |
57 | MESSAGE(ERROR "random_choice_in_0123 = ${random_choice_in_0123}") | |
58 | ENDIF( ${random_choice_in_0123} STREQUAL 0 ) | |
59 | # | |
60 | IF( alternate ) | |
61 | SET(debug_list "") | |
62 | SET(release_list "") | |
63 | SET(count_mod_2 "${random_choice_in_0123}") | |
64 | FOREACH(source ${source_list}) | |
65 | MATH(EXPR count_mod_2 "(${count_mod_2} + 1) % 2") | |
66 | IF( count_mod_2 ) | |
67 | add_to_list(debug_list ${source}) | |
68 | ELSE( count_mod_2 ) | |
69 | add_to_list(release_list ${source}) | |
70 | ENDIF( count_mod_2 ) | |
71 | ENDFOREACH(source ${source_list}) | |
72 | SET_SOURCE_FILES_PROPERTIES( | |
73 | ${debug_list} PROPERTIES COMPILE_FLAGS | |
74 | "${debug_flags} -DCPPAD_DEBUG_AND_RELEASE" | |
75 | ) | |
76 | SET_SOURCE_FILES_PROPERTIES( | |
77 | ${release_list} PROPERTIES COMPILE_FLAGS | |
78 | "${release_flags} -DCPPAD_DEBUG_AND_RELEASE" | |
79 | ) | |
80 | ENDIF( alternate ) | |
81 | ENDFUNCTION(random_debug_release program_name source_list) |
0 | # ----------------------------------------------------------------------------- | |
1 | # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell | |
2 | # | |
3 | # CppAD is distributed under multiple licenses. This distribution is under | |
4 | # the terms of the | |
5 | # Eclipse Public License Version 1.0. | |
6 | # | |
7 | # A copy of this license is included in the COPYING file of this distribution. | |
8 | # Please visit http://www.coin-or.org/CppAD/ for information on other licenses. | |
9 | # ----------------------------------------------------------------------------- | |
10 | # set_compile_flags( program_name debug_which source_list) | |
11 | # | |
12 | # program_name: (in) | |
13 | # Is the name of the program that we are building. This is only used to | |
14 | # report which files have debug and which have release properties. | |
15 | # | |
16 | # debug_which: (in) | |
17 | # Is one of the following cases: | |
18 | # | |
19 | # Case debug_even: | |
20 | # The files with an even (odd) index in source_list have debug (release) flags. | |
21 | # In addition the compiler flag -DCPPAD_DEBUG_AND_RELEASE is added. | |
22 | # | |
23 | # Case debug_odd: | |
24 | # The files with an odd (even) index in source_list have debug (release) flags. | |
25 | # In addition the compiler flag -DCPPAD_DEBUG_AND_RELEASE is added. | |
26 | # | |
27 | # Case debug_all: | |
28 | # All the files have debug flags. | |
29 | # | |
30 | # Case debug_none: | |
31 | # All the the files have release flags. | |
32 | # | |
33 | # source_list: (in) | |
34 | # is a list of source files that get set to have debug or release | |
35 | # compile flags. The cppad_cxx_flags compile flags always get included. | |
36 | # | |
37 | FUNCTION(set_compile_flags program_name debug_which source_list) | |
38 | # debug compile flags | |
39 | SET(debug_flags "${cppad_cxx_flags} ${CMAKE_CXX_FLAGS_DEBUG}") | |
40 | # relese compile flags | |
41 | SET(release_flags "${cppad_cxx_flags} ${CMAKE_CXX_FLAGS_RELEASE}") | |
42 | # | |
43 | # set alternate, report random number result, | |
44 | # set compile flags property when not alternating. | |
45 | IF( "${debug_which}" STREQUAL "debug_even" ) | |
46 | SET(alternate TRUE) | |
47 | SET(count_mod_2 0) | |
48 | ELSEIF( "${debug_which}" STREQUAL "debug_odd" ) | |
49 | SET(alternate TRUE) | |
50 | SET(count_mod_2 1) | |
51 | ELSEIF( "${debug_which}" STREQUAL "debug_all" ) | |
52 | SET(alternate FALSE) | |
53 | SET_SOURCE_FILES_PROPERTIES( | |
54 | ${source_list} PROPERTIES COMPILE_FLAGS "${debug_flags}" | |
55 | ) | |
56 | ELSEIF( "${debug_which}" STREQUAL "debug_none" ) | |
57 | SET(alternate FALSE) | |
58 | SET_SOURCE_FILES_PROPERTIES( | |
59 | ${source_list} PROPERTIES COMPILE_FLAGS "${release_flags}" | |
60 | ) | |
61 | ELSE( "${debug_which}" ) | |
62 | MESSAGE(FATAL_ERROR "cmake error: debug_which = ${debug_which}") | |
63 | ENDIF( "${debug_which}" STREQUAL "debug_even" ) | |
64 | # | |
65 | IF( alternate ) | |
66 | SET(debug_list "") | |
67 | SET(release_list "") | |
68 | FOREACH(source ${source_list}) | |
69 | MATH(EXPR count_mod_2 "(${count_mod_2} + 1) % 2") | |
70 | IF( count_mod_2 ) | |
71 | add_to_list(debug_list ${source}) | |
72 | ELSE( count_mod_2 ) | |
73 | add_to_list(release_list ${source}) | |
74 | ENDIF( count_mod_2 ) | |
75 | ENDFOREACH(source ${source_list}) | |
76 | SET_SOURCE_FILES_PROPERTIES( | |
77 | ${debug_list} PROPERTIES COMPILE_FLAGS | |
78 | "${debug_flags} -DCPPAD_DEBUG_AND_RELEASE" | |
79 | ) | |
80 | SET_SOURCE_FILES_PROPERTIES( | |
81 | ${release_list} PROPERTIES COMPILE_FLAGS | |
82 | "${release_flags} -DCPPAD_DEBUG_AND_RELEASE" | |
83 | ) | |
84 | ENDIF( alternate ) | |
85 | ENDFUNCTION(set_compile_flags program_name debug_which source_list) |
35 | 35 | set_sparsity.cpp |
36 | 36 | tangent.cpp |
37 | 37 | ) |
38 | # | |
39 | # set compiler flags | |
40 | random_debug_release(example_atomic "${source_list}") | |
38 | set_compile_flags( example_atomic "${cppad_debug_which}" "${source_list}" ) | |
41 | 39 | # |
42 | 40 | ADD_EXECUTABLE(example_atomic EXCLUDE_FROM_ALL ${source_list}) |
43 | 41 | # |
20 | 20 | track_new_del.cpp |
21 | 21 | zdouble.cpp |
22 | 22 | ) |
23 | ||
24 | # Compiler flags for cppad source | |
25 | random_debug_release(example_deprecated "${source_list}") | |
23 | set_compile_flags( example_deprecated "${cppad_debug_which}" "${source_list}" ) | |
26 | 24 | # |
27 | 25 | ADD_EXECUTABLE(example_deprecated EXCLUDE_FROM_ALL ${source_list}) |
28 | 26 | # |
134 | 134 | var2par.cpp |
135 | 135 | vec_ad.cpp |
136 | 136 | ) |
137 | # set compiler flags | |
138 | random_debug_release(example_general "${source_list}") | |
137 | set_compile_flags( example_general "${cppad_debug_which}" "${source_list}" ) | |
139 | 138 | # |
140 | 139 | ADD_EXECUTABLE(example_general EXCLUDE_FROM_ALL ${source_list}) |
141 | 140 | # |
11 | 11 | # |
12 | 12 | SET(source_list get_started.cpp) |
13 | 13 | # |
14 | # set compiler flags | |
15 | random_debug_release(example_get_started "${source_list}") | |
14 | set_compile_flags( example_get_started "${cppad_debug_which}" "${source_list}" ) | |
16 | 15 | # |
17 | 16 | ADD_EXECUTABLE(example_get_started EXCLUDE_FROM_ALL ${source_list}) |
18 | 17 | # |
18 | 18 | ode_inverse.cpp |
19 | 19 | retape.cpp |
20 | 20 | ) |
21 | # set compiler flags | |
22 | random_debug_releAse( example_ipopt_solve "${source_list}") | |
21 | set_compile_flags( example_ipopt_solve "${cppad_debug_which}" "${source_list}" ) | |
23 | 22 | # |
24 | 23 | ADD_EXECUTABLE(example_ipopt_solve EXCLUDE_FROM_ALL ${source_list}) |
25 | 24 | # |
20 | 20 | optimize.cpp |
21 | 21 | reverse_active.cpp |
22 | 22 | ) |
23 | # | |
24 | # set compiler flags | |
25 | random_debug_release( example_optimize "${source_list}") | |
23 | set_compile_flags( example_optimize "${cppad_debug_which}" "${source_list}" ) | |
26 | 24 | # |
27 | 25 | ADD_EXECUTABLE(example_optimize EXCLUDE_FROM_ALL ${source_list}) |
28 | 26 |
11 | 11 | # |
12 | 12 | SET(source_list print_for.cpp) |
13 | 13 | # |
14 | # set compiler flags | |
15 | random_debug_release(example_print_for "${source_list}") | |
14 | set_compile_flags( example_print_for "${cppad_debug_which}" "${source_list}" ) | |
16 | 15 | # |
17 | 16 | ADD_EXECUTABLE(example_print_for EXCLUDE_FROM_ALL ${source_list}) |
18 | 17 |
32 | 32 | colpack_hes.cpp |
33 | 33 | rc_sparsity.cpp |
34 | 34 | ) |
35 | # | |
36 | # set compiler flags | |
37 | random_debug_release( example_sparse "${source_list}") | |
35 | set_compile_flags( example_sparse "${cppad_debug_which}" "${source_list}" ) | |
38 | 36 | # |
39 | 37 | ADD_EXECUTABLE(example_sparse EXCLUDE_FROM_ALL ${source_list}) |
40 | 38 |
35 | 35 | utility.cpp |
36 | 36 | vector_bool.cpp |
37 | 37 | ) |
38 | # | |
39 | # set compiler flags | |
40 | random_debug_release( example_utility "${source_list}") | |
38 | set_compile_flags( example_utility "${cppad_debug_which}" "${source_list}" ) | |
41 | 39 | # |
42 | 40 | ADD_EXECUTABLE(example_utility EXCLUDE_FROM_ALL ${source_list}) |
43 | 41 | # |