Codebase list cppad / fd8d149
debug_rel branch: Change random_debug_release -> set_compile_flags. Brad Bell 6 years ago
13 changed file(s) with 108 addition(s) and 110 deletion(s). Raw diff Collapse all Expand all
6969 # print_variable(variable)
7070 INCLUDE(cmake/print_variable.cmake)
7171 #
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)
7474 # =============================================================================
7575 # command line arguments
7676 # =============================================================================
188188 # =============================================================================
189189 # Make a random choice from the set {0, 1, 2, 3}
190190 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)
192201 # =============================================================================
193202 # cppad_has_colpack, colpack_libs, cppad_lib
194203 #
+0
-82
cmake/random_debug_release.cmake less more
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)
3535 set_sparsity.cpp
3636 tangent.cpp
3737 )
38 #
39 # set compiler flags
40 random_debug_release(example_atomic "${source_list}")
38 set_compile_flags( example_atomic "${cppad_debug_which}" "${source_list}" )
4139 #
4240 ADD_EXECUTABLE(example_atomic EXCLUDE_FROM_ALL ${source_list})
4341 #
2020 track_new_del.cpp
2121 zdouble.cpp
2222 )
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}" )
2624 #
2725 ADD_EXECUTABLE(example_deprecated EXCLUDE_FROM_ALL ${source_list})
2826 #
134134 var2par.cpp
135135 vec_ad.cpp
136136 )
137 # set compiler flags
138 random_debug_release(example_general "${source_list}")
137 set_compile_flags( example_general "${cppad_debug_which}" "${source_list}" )
139138 #
140139 ADD_EXECUTABLE(example_general EXCLUDE_FROM_ALL ${source_list})
141140 #
1111 #
1212 SET(source_list get_started.cpp)
1313 #
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}" )
1615 #
1716 ADD_EXECUTABLE(example_get_started EXCLUDE_FROM_ALL ${source_list})
1817 #
1818 ode_inverse.cpp
1919 retape.cpp
2020 )
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}" )
2322 #
2423 ADD_EXECUTABLE(example_ipopt_solve EXCLUDE_FROM_ALL ${source_list})
2524 #
2020 optimize.cpp
2121 reverse_active.cpp
2222 )
23 #
24 # set compiler flags
25 random_debug_release( example_optimize "${source_list}")
23 set_compile_flags( example_optimize "${cppad_debug_which}" "${source_list}" )
2624 #
2725 ADD_EXECUTABLE(example_optimize EXCLUDE_FROM_ALL ${source_list})
2826
1111 #
1212 SET(source_list print_for.cpp)
1313 #
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}" )
1615 #
1716 ADD_EXECUTABLE(example_print_for EXCLUDE_FROM_ALL ${source_list})
1817
3232 colpack_hes.cpp
3333 rc_sparsity.cpp
3434 )
35 #
36 # set compiler flags
37 random_debug_release( example_sparse "${source_list}")
35 set_compile_flags( example_sparse "${cppad_debug_which}" "${source_list}" )
3836 #
3937 ADD_EXECUTABLE(example_sparse EXCLUDE_FROM_ALL ${source_list})
4038
3535 utility.cpp
3636 vector_bool.cpp
3737 )
38 #
39 # set compiler flags
40 random_debug_release( example_utility "${source_list}")
38 set_compile_flags( example_utility "${cppad_debug_which}" "${source_list}" )
4139 #
4240 ADD_EXECUTABLE(example_utility EXCLUDE_FROM_ALL ${source_list})
4341 #
137137
138138 local/vector_set.cpp
139139 )
140 #
141 random_debug_release(test_more_general "${source_list}")
140 set_compile_flags( test_more_general "${cppad_debug_which}" "${source_list}" )
142141 #
143142 ADD_EXECUTABLE(test_more_general EXCLUDE_FROM_ALL ${source_list})
144143 #