diff --git a/examples/arkode/C_manyvector/CMakeLists.txt b/examples/arkode/C_manyvector/CMakeLists.txt index 5e8e83f9ea..fc16e58b1b 100644 --- a/examples/arkode/C_manyvector/CMakeLists.txt +++ b/examples/arkode/C_manyvector/CMakeLists.txt @@ -43,10 +43,23 @@ foreach(example_tuple ${ARKODE_examples}) PARAMS_VAR example_args TYPE_VAR example_type ) - # example source files - add_executable(${example} ${example}) + # check if this example has already been added, only need to add + # example source files once for testing with different inputs + if(NOT TARGET ${example}) + # example source files + add_executable(${example} ${example}) + + # folder to organize targets in an IDE + set_target_properties(${example} PROPERTIES FOLDER "Examples") + + # libraries to link against + target_link_libraries(${example} ${SUNDIALS_LIBS}) + endif() + + # check if example args are provided and set the test name + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) - set_target_properties(${example} PROPERTIES FOLDER "Examples") # add example to regression tests sundials_add_test(${example} ${example} @@ -54,9 +67,6 @@ foreach(example_tuple ${ARKODE_examples}) ANSWER_FILE ${example}.out EXAMPLE_TYPE ${example_type}) - # libraries to link against - target_link_libraries(${example} ${SUNDIALS_LIBS}) - endforeach(example_tuple ${ARKODE_examples}) # create Makfile and CMakeLists.txt for examples diff --git a/examples/arkode/C_serial/CMakeLists.txt b/examples/arkode/C_serial/CMakeLists.txt index b7fd38bf30..0e5de82164 100644 --- a/examples/arkode/C_serial/CMakeLists.txt +++ b/examples/arkode/C_serial/CMakeLists.txt @@ -140,11 +140,8 @@ foreach(example_tuple ${ARKODE_examples}) endif() # check if example args are provided and set the test name - if("${example_args}" STREQUAL "") - set(test_name ${example}) - else() - string(REGEX REPLACE " " "_" test_name ${example}_${example_args}) - endif() + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) # add example to regression tests sundials_add_test(${test_name} ${example} @@ -167,16 +164,12 @@ if(BUILD_SUNLINSOL_KLU) TYPE_VAR example_type ) - # example source files - add_executable(${example} ${example}) - - set_target_properties(${example} PROPERTIES FOLDER "Examples") + if (NOT TARGET ${example}) + # example source files + add_executable(${example} ${example}) - # add example to regression tests - sundials_add_test(${example} ${example} - ANSWER_DIR ${CMAKE_CURRENT_SOURCE_DIR} - ANSWER_FILE ${example}.out - EXAMPLE_TYPE ${example_type}) + # folder for IDEs + set_target_properties(${example} PROPERTIES FOLDER "Examples") # libraries to link against target_link_libraries(${example} @@ -184,6 +177,17 @@ if(BUILD_SUNLINSOL_KLU) sundials_nvecserial sundials_sunlinsolklu ${EXE_EXTRA_LINK_LIBS}) + endif() + + # check if example args are provided and set the test name + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) + + # add example to regression tests + sundials_add_test(${example} ${example} + ANSWER_DIR ${CMAKE_CURRENT_SOURCE_DIR} + ANSWER_FILE ${example}.out + EXAMPLE_TYPE ${example_type}) endforeach(example_tuple ${ARKODE_examples_KLU}) @@ -202,23 +206,30 @@ if(BUILD_SUNLINSOL_SUPERLUMT) TYPE_VAR example_type ) + if (NOT TARGET ${example}) # example source files add_executable(${example} ${example}) + # folder for IDEs set_target_properties(${example} PROPERTIES FOLDER "Examples") - # add example to regression tests - sundials_add_test(${example} ${example} - ANSWER_DIR ${CMAKE_CURRENT_SOURCE_DIR} - ANSWER_FILE ${example}.out - EXAMPLE_TYPE ${example_type}) - # libraries to link against target_link_libraries(${example} sundials_arkode sundials_nvecserial sundials_sunlinsolsuperlumt ${EXE_EXTRA_LINK_LIBS}) + endif() + + # check if example args are provided and set the test name + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) + + # add example to regression tests + sundials_add_test(${example} ${example} + ANSWER_DIR ${CMAKE_CURRENT_SOURCE_DIR} + ANSWER_FILE ${example}.out + EXAMPLE_TYPE ${example_type}) endforeach(example_tuple ${ARKODE_examples_SUPERLUMT}) diff --git a/examples/cvode/serial/CMakeLists.txt b/examples/cvode/serial/CMakeLists.txt index 88e38b3a28..9ae55874ee 100644 --- a/examples/cvode/serial/CMakeLists.txt +++ b/examples/cvode/serial/CMakeLists.txt @@ -102,11 +102,8 @@ foreach(example_tuple ${CVODE_examples}) endif() # check if example args are provided and set the test name - if("${example_args}" STREQUAL "") - set(test_name ${example}) - else() - string(REGEX REPLACE " " "_" test_name ${example}_${example_args}) - endif() + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) # add example to regression tests sundials_add_test(${test_name} ${example} @@ -153,12 +150,9 @@ if(BUILD_SUNLINSOL_LAPACKBAND AND BUILD_SUNLINSOL_LAPACKDENSE) target_link_libraries(${example} ${SUNDIALS_LIBS} ${SUNLINSOLLAPACK_LIBS}) endif() - # check if example args are provided and set the test name - if("${example_args}" STREQUAL "") - set(test_name ${example}) - else() - string(REGEX REPLACE " " "_" test_name ${example}_${example_args}) - endif() + # check if example args are provided and set the test name + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) # add example to regression tests sundials_add_test(${test_name} ${example} @@ -205,12 +199,9 @@ if(BUILD_SUNLINSOL_KLU) target_link_libraries(${example} ${SUNDIALS_LIBS} ${SUNLINSOLKLU_LIBS}) endif() - # check if example args are provided and set the test name - if("${example_args}" STREQUAL "") - set(test_name ${example}) - else() - string(REGEX REPLACE " " "_" test_name ${example}_${example_args}) - endif() + # check if example args are provided and set the test name + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) # add example to regression tests sundials_add_test(${test_name} ${example} @@ -257,12 +248,9 @@ if(BUILD_SUNLINSOL_SUPERLUMT) target_link_libraries(${example} ${SUNDIALS_LIBS} ${SUNLINSOLSLUMT_LIBS}) endif() - # check if example args are provided and set the test name - if("${example_args}" STREQUAL "") - set(test_name ${example}) - else() - string(REGEX REPLACE " " "_" test_name ${example}_${example_args}) - endif() + # check if example args are provided and set the test name + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) # Do not include SuperLUMT examples in testing when the indextype is int64_t. # Answer files were generated with int32_t and minor differences in output diff --git a/examples/cvodes/serial/CMakeLists.txt b/examples/cvodes/serial/CMakeLists.txt index ad73fa3c7a..47ce140763 100644 --- a/examples/cvodes/serial/CMakeLists.txt +++ b/examples/cvodes/serial/CMakeLists.txt @@ -115,11 +115,8 @@ foreach(example_tuple ${CVODES_examples}) endif() # check if example args are provided and set the test name - if("${example_args}" STREQUAL "") - set(test_name ${example}) - else() - string(REGEX REPLACE " " "_" test_name ${example}_${example_args}) - endif() + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) # add example to regression tests sundials_add_test(${test_name} ${example} @@ -166,12 +163,9 @@ if(BUILD_SUNLINSOL_LAPACKBAND AND BUILD_SUNLINSOL_LAPACKDENSE) target_link_libraries(${example} ${SUNDIALS_LIBS} ${SUNLINSOLLAPACK_LIBS}) endif() - # check if example args are provided and set the test name - if("${example_args}" STREQUAL "") - set(test_name ${example}) - else() - string(REGEX REPLACE " " "_" test_name ${example}_${example_args}) - endif() + # check if example args are provided and set the test name + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) # add example to regression tests sundials_add_test(${test_name} ${example} @@ -217,12 +211,9 @@ if(BUILD_SUNLINSOL_KLU) target_link_libraries(${example} ${SUNDIALS_LIBS} ${SUNLINSOLKLU_LIBS}) endif() - # check if example args are provided and set the test name - if("${example_args}" STREQUAL "") - set(test_name ${example}) - else() - string(REGEX REPLACE " " "_" test_name ${example}_${example_args}) - endif() + # check if example args are provided and set the test name + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) # add example to regression tests sundials_add_test(${test_name} ${example} @@ -268,13 +259,9 @@ if(BUILD_SUNLINSOL_SUPERLUMT) # libraries to link against target_link_libraries(${example} ${SUNDIALS_LIBS} ${SUNLINSOLSLUMT_LIBS}) endif() - - # check if example args are provided and set the test name - if("${example_args}" STREQUAL "") - set(test_name ${example}) - else() - string(REGEX REPLACE " " "_" test_name ${example}_${example_args}) - endif() + # check if example args are provided and set the test name + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) # Do not include SuperLUMT examples in testing when the indextype is int32_t. # Answer files were generated with int64_t and minor differences in output diff --git a/examples/ida/parallel/CMakeLists.txt b/examples/ida/parallel/CMakeLists.txt index 3e5ca4b335..552c9567ac 100644 --- a/examples/ida/parallel/CMakeLists.txt +++ b/examples/ida/parallel/CMakeLists.txt @@ -52,25 +52,30 @@ foreach(example_tuple ${IDA_examples}) TYPE_VAR example_type ) - # example source files - add_executable(${example} ${example}) + if(NOT TARGET ${example}) + # example source files + add_executable(${example} ${example}) - set_target_properties(${example} PROPERTIES FOLDER "Examples") + set_target_properties(${example} PROPERTIES FOLDER "Examples") + # libraries to link against + target_link_libraries(${example} ${SUNDIALS_LIBS}) + + if(NOT MPI_C_COMPILER) + target_link_libraries(${example} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARIES}) + endif() + endif() + # check if example args are provided and set the test name + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args} MPI_NPROCS ${number_of_tasks}) + # add example to regression tests - sundials_add_test(${example} ${example} + sundials_add_test(${test_name} ${example} MPI_NPROCS ${number_of_tasks} ANSWER_DIR ${CMAKE_CURRENT_SOURCE_DIR} ANSWER_FILE ${example}.out EXAMPLE_TYPE ${example_type}) - # libraries to link against - target_link_libraries(${example} ${SUNDIALS_LIBS}) - - if(NOT MPI_C_COMPILER) - target_link_libraries(${example} ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARIES}) - endif() - endforeach(example_tuple ${IDA_examples}) # create Makfile and CMakeLists.txt for examples diff --git a/examples/idas/serial/CMakeLists.txt b/examples/idas/serial/CMakeLists.txt index 59a2f6efa4..f3eb08a17a 100644 --- a/examples/idas/serial/CMakeLists.txt +++ b/examples/idas/serial/CMakeLists.txt @@ -94,11 +94,8 @@ foreach(example_tuple ${IDAS_examples}) endif() # check if example args are provided and set the test name - if("${example_args}" STREQUAL "") - set(test_name ${example}) - else() - string(REGEX REPLACE " " "_" test_name ${example}_${example_args}) - endif() + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) # add example to regression tests sundials_add_test(${test_name} ${example} @@ -145,12 +142,9 @@ if(BUILD_SUNLINSOL_LAPACKBAND AND BUILD_SUNLINSOL_LAPACKDENSE) target_link_libraries(${example} ${SUNDIALS_LIBS} ${SUNLINSOLLAPACK_LIBS}) endif() - # check if example args are provided and set the test name - if("${example_args}" STREQUAL "") - set(test_name ${example}) - else() - string(REGEX REPLACE " " "_" test_name ${example}_${example_args}) - endif() + # check if example args are provided and set the test name + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) # add example to regression tests sundials_add_test(${test_name} ${example} @@ -197,12 +191,9 @@ if(BUILD_SUNLINSOL_KLU) target_link_libraries(${example} ${SUNDIALS_LIBS} ${SUNLINSOLKLU_LIBS}) endif() - # check if example args are provided and set the test name - if("${example_args}" STREQUAL "") - set(test_name ${example}) - else() - string(REGEX REPLACE " " "_" test_name ${example}_${example_args}) - endif() + # check if example args are provided and set the test name + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) # add example to regression tests sundials_add_test(${test_name} ${example} @@ -249,12 +240,9 @@ if(BUILD_SUNLINSOL_SUPERLUMT) target_link_libraries(${example} ${SUNDIALS_LIBS} ${SUNLINSOLSLUMT_LIBS}) endif() - # check if example args are provided and set the test name - if("${example_args}" STREQUAL "") - set(test_name ${example}) - else() - string(REGEX REPLACE " " "_" test_name ${example}_${example_args}) - endif() + # check if example args are provided and set the test name + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) # Do not include SuperLUMT examples in testing when the indextype is int64_t. # Answer files were generated with int32_t and minor differences in output diff --git a/examples/kinsol/serial/CMakeLists.txt b/examples/kinsol/serial/CMakeLists.txt index 5844a1913b..79b601c529 100644 --- a/examples/kinsol/serial/CMakeLists.txt +++ b/examples/kinsol/serial/CMakeLists.txt @@ -89,11 +89,8 @@ foreach(example_tuple ${KINSOL_examples}) endif() # check if example args are provided and set the test name - if("${example_args}" STREQUAL "") - set(test_name ${example}) - else() - string(REGEX REPLACE " " "_" test_name ${example}_${example_args}) - endif() + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) # add example to regression tests sundials_add_test(${test_name} ${example} @@ -125,10 +122,24 @@ if(BUILD_SUNLINSOL_LAPACKBAND AND BUILD_SUNLINSOL_LAPACKDENSE) PARAMS_VAR example_args TYPE_VAR example_type ) - # example source files - add_executable(${example} ${example}) - set_target_properties(${example} PROPERTIES FOLDER "Examples") + # check if this example has already been added, only need to add + # example source files once for testing with different inputs + if(NOT TARGET ${example}) + + # example source files + add_executable(${example} ${example}) + + set_target_properties(${example} PROPERTIES FOLDER "Examples") + + # libraries to link against + target_link_libraries(${example} ${SUNDIALS_LIBS} ${SUNLINSOLLAPACK_LIBS}) + + endif() + + # check if example args are provided and set the test name + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) # add example to regression tests sundials_add_test(${example} ${example} @@ -136,9 +147,6 @@ if(BUILD_SUNLINSOL_LAPACKBAND AND BUILD_SUNLINSOL_LAPACKDENSE) ANSWER_FILE ${example}.out EXAMPLE_TYPE ${example_type}) - # libraries to link against - target_link_libraries(${example} ${SUNDIALS_LIBS} ${SUNLINSOLLAPACK_LIBS}) - endforeach(example_tuple ${KINSOL_examples_BL}) endif() @@ -161,10 +169,24 @@ if(BUILD_SUNLINSOL_KLU) TYPE_VAR example_type ) - # example source files - add_executable(${example} ${example}) + # check if this example has already been added, only need to add + # example source files once for testing with different inputs + if(NOT TARGET ${example}) + + # example source files + add_executable(${example} ${example}) + + set_target_properties(${example} PROPERTIES FOLDER "Examples") + + # libraries to link against + target_link_libraries(${example} ${SUNDIALS_LIBS} ${SUNLINSOLKLU_LIBS}) + + endif() + + # check if example args are provided and set the test name + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) - set_target_properties(${example} PROPERTIES FOLDER "Examples") # add example to regression tests sundials_add_test(${example} ${example} @@ -172,9 +194,6 @@ if(BUILD_SUNLINSOL_KLU) ANSWER_FILE ${example}.out EXAMPLE_TYPE ${example_type}) - # libraries to link against - target_link_libraries(${example} ${SUNDIALS_LIBS} ${SUNLINSOLKLU_LIBS}) - endforeach(example_tuple ${KINSOL_examples_KLU}) endif() @@ -196,11 +215,23 @@ if(BUILD_SUNLINSOL_SUPERLUMT) PARAMS_VAR example_args TYPE_VAR example_type ) + # check if this example has already been added, only need to add + # example source files once for testing with different inputs + if(NOT TARGET ${example}) - # example source files - add_executable(${example} ${example}) + # example source files + add_executable(${example} ${example}) - set_target_properties(${example} PROPERTIES FOLDER "Examples") + set_target_properties(${example} PROPERTIES FOLDER "Examples") + + # libraries to link against + target_link_libraries(${example} ${SUNDIALS_LIBS} ${SUNLINSOLSLUMT_LIBS}) + + endif() + + # check if example args are provided and set the test name + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) # add example to regression tests sundials_add_test(${example} ${example} @@ -208,9 +239,6 @@ if(BUILD_SUNLINSOL_SUPERLUMT) ANSWER_FILE ${example}.out EXAMPLE_TYPE ${example_type}) - # libraries to link against - target_link_libraries(${example} ${SUNDIALS_LIBS} ${SUNLINSOLSLUMT_LIBS}) - endforeach(example_tuple ${KINSOL_examples_SUPERLUMT}) endif() diff --git a/examples/nvector/manyvector/CMakeLists.txt b/examples/nvector/manyvector/CMakeLists.txt index c822e3207a..d16675bedd 100644 --- a/examples/nvector/manyvector/CMakeLists.txt +++ b/examples/nvector/manyvector/CMakeLists.txt @@ -81,11 +81,8 @@ foreach(example_tuple ${nvector_manyvector_examples}) endif() # check if example args are provided and set the test name - if("${example_args}" STREQUAL "") - set(test_name ${example}) - else() - string(REGEX REPLACE " " "_" test_name ${example}_${example_args}) - endif() + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) # add example to regression tests sundials_add_test(${test_name} ${example} @@ -122,11 +119,8 @@ foreach(example_tuple ${nvector_manyvector_fortran_examples}) endif() # check if example args are provided and set the test name - if("${example_args}" STREQUAL "") - set(test_name ${example}) - else() - string(REGEX REPLACE " " "_" test_name ${example}_${example_args}) - endif() + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) # add example to regression tests sundials_add_test(${test_name} ${example} diff --git a/examples/nvector/serial/CMakeLists.txt b/examples/nvector/serial/CMakeLists.txt index 1bed7b54a7..892dbba6ef 100644 --- a/examples/nvector/serial/CMakeLists.txt +++ b/examples/nvector/serial/CMakeLists.txt @@ -81,11 +81,8 @@ foreach(example_tuple ${nvector_serial_examples}) endif() # check if example args are provided and set the test name - if("${example_args}" STREQUAL "") - set(test_name ${example}) - else() - string(REGEX REPLACE " " "_" test_name ${example}_${example_args}) - endif() + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) # add example to regression tests sundials_add_test(${test_name} ${example} @@ -124,11 +121,8 @@ foreach(example_tuple ${nvector_serial_fortran_examples}) endif() # check if example args are provided and set the test name - if("${example_args}" STREQUAL "") - set(test_name ${example}) - else() - string(REGEX REPLACE " " "_" test_name ${example}_${example_args}) - endif() + sundials_create_test_name(${example} test_name + TEST_ARGS ${example_args}) # add example to regression tests sundials_add_test(${test_name} ${example}