@@ -89,6 +89,21 @@ macro(SUNDIALS_ADD_TEST NAME EXECUTABLE)
89
89
cmake_parse_arguments (SUNDIALS_ADD_TEST "${options} " "${oneValueArgs} "
90
90
"${multiValueArgs} " ${ARGN} )
91
91
92
+ # check if any options for setting command line args have been provided by
93
+ # comparing them against an empty string -- this is needed to avoid missing
94
+ # single args that are a false constant in CMake e.g., 0, FALSE, OFF, etc.
95
+ if ("${SUNDIALS_ADD_TEST_TEST_ARGS} " STREQUAL "" )
96
+ set (_have_test_args FALSE )
97
+ else ()
98
+ set (_have_test_args TRUE )
99
+ endif ()
100
+
101
+ if ("${SUNDIALS_ADD_TEST_EXTRA_ARGS} " STREQUAL "" )
102
+ set (_have_extra_test_args FALSE )
103
+ else ()
104
+ set (_have_extra_test_args TRUE )
105
+ endif ()
106
+
92
107
# check that the test is not excluded
93
108
string (TOLOWER "exclude-${SUNDIALS_PRECISION} " _exclude_precision)
94
109
if (("${SUNDIALS_ADD_TEST_EXAMPLE_TYPE} " STREQUAL "exclude" )
@@ -186,17 +201,17 @@ macro(SUNDIALS_ADD_TEST NAME EXECUTABLE)
186
201
endif ()
187
202
188
203
# set the test input args
189
- if (SUNDIALS_ADD_TEST_TEST_ARGS )
204
+ if (_have_test_args )
190
205
string (REPLACE ";" " " _user_args "${SUNDIALS_ADD_TEST_TEST_ARGS} " )
191
206
set (_run_args "${_user_args} " )
192
207
unset (_user_args)
193
208
endif ()
194
- if (SUNDIALS_ADD_TEST_EXTRA_ARGS )
209
+ if (_have_extra_test_args )
195
210
string (REPLACE ";" " " _extra_args "${SUNDIALS_ADD_TEST_EXTRA_ARGS} " )
196
211
set (_run_args "${_run_args} ${_extra_args} " )
197
212
unset (_extra_args)
198
213
endif ()
199
- if (_run_args )
214
+ if (_have_test_args OR _have_extra_test_args )
200
215
string (STRIP "${_run_args} " _run_args)
201
216
list (APPEND TEST_ARGS "--runargs=\" ${_run_args} \" " )
202
217
unset (_run_args)
@@ -214,7 +229,7 @@ macro(SUNDIALS_ADD_TEST NAME EXECUTABLE)
214
229
# pass/fail
215
230
216
231
# convert string to list
217
- if (SUNDIALS_ADD_TEST_TEST_ARGS )
232
+ if (_have_test_args )
218
233
string (REPLACE " " ";" TEST_ARGS "${SUNDIALS_ADD_TEST_TEST_ARGS} " )
219
234
endif ()
220
235
0 commit comments