From 5692dd8211bccfe69954ff99a429f23acfe856ed Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Thu, 26 Mar 2015 17:10:35 +0100 Subject: [PATCH] CMake: Improve DEAL_II_ADD_TEST macro - For every deal.II build type (given by the variable DEAL_II_BUILD_TYPES) that is a (case insensitive) substring of CMAKE_BUILD_TYPE a test is defined. --- cmake/macros/macro_deal_ii_add_test.cmake | 59 +++++++++++++------ ..._deal_ii_initialize_cached_variables.cmake | 7 +-- tests/setup_testsubproject.cmake | 4 +- 3 files changed, 46 insertions(+), 24 deletions(-) diff --git a/cmake/macros/macro_deal_ii_add_test.cmake b/cmake/macros/macro_deal_ii_add_test.cmake index c2df104830..e0d2206800 100644 --- a/cmake/macros/macro_deal_ii_add_test.cmake +++ b/cmake/macros/macro_deal_ii_add_test.cmake @@ -16,30 +16,39 @@ # # A Macro to set up tests for the testsuite # -# The following variables must be set: -# -# TEST_DIFF -# - specifying the executable and command line of the diff command to use -# -# TEST_TIME_LIMIT -# - specifying the maximal wall clock time in seconds a test is allowed -# to run -# -# -# Usage: -# DEAL_II_ADD_TEST(category test_name comparison_file) -# # This macro assumes that a source file "./tests/category/.cc" # as well as the comparison file "" is available in the # testsuite. The output of compiled source file is compared against the # file comparison file. # +# For every deal.II build type (given by the variable DEAL_II_BUILD_TYPES) that +# is a (case insensitive) substring of CMAKE_BUILD_TYPE a test is defined. +# # This macro gets the following options from the comparison file name (have # a look at the testsuite documentation for details): # - usage of mpirun and number of simultaneous processes # - valid build configurations # - expected test stage # +# The following variables must be set: +# +# TEST_DIFF +# - specifying the executable and command line of the diff command to use +# +# TEST_TIME_LIMIT +# - specifying the maximal wall clock time in seconds a test is allowed +# to run +# +# The following variables may be set: +# +# TEST_LIBRARIES +# TEST_LIBRARIES_DEBUG +# TEST_LIBRARIES_RELEASE +# - specifying additional libraries (and targets) to link against. +# +# Usage: +# DEAL_II_ADD_TEST(category test_name comparison_file) +# MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file) @@ -103,12 +112,24 @@ MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file) ENDIF() # - # Determine for which build types a test should be defined: + # Determine for which build types a test should be defined. Every deal.II + # build type (given by the list DEAL_II_BUILD_TYPES) that is a (case + # insensitive) substring of CMAKE_BUILD_TYPE: # - - + SET(_build_types "") FOREACH(_build ${DEAL_II_BUILD_TYPES}) + STRING(TOLOWER ${_build} _build_lowercase) + STRING(TOLOWER ${CMAKE_BUILD_TYPE} _cmake_build_type) + IF("${_cmake_build_type}" MATCHES "${_build_lowercase}") + LIST(APPEND _build_types ${_build}) + ENDIF() + ENDFOREACH() + + FOREACH(_build ${_build_types}) + # + # Obey "debug" and "release" keywords in the output file: + # ITEM_MATCHES(_match "${_build}" ${_configuration}) IF(_match OR "${_configuration}" STREQUAL "") @@ -162,7 +183,7 @@ MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file) ) DEAL_II_SETUP_TARGET(${_target} ${_build}) TARGET_LINK_LIBRARIES(${_target} - ${TARGET_LIBRARIES} ${TARGET_LIBRARIES_${_build}} + ${TEST_LIBRARIES} ${TEST_LIBRARIES_${_build}} ) SET_TARGET_PROPERTIES(${_target} PROPERTIES @@ -204,8 +225,8 @@ MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file) COMMAND touch ${_test_directory}/diff COMMAND - # run diff or numdiff (if available) to determine - # whether files are the same. if they are not, output + # run diff or numdiff (if available) to determine + # whether files are the same. if they are not, output # the first few lines of the output of numdiff, followed # by the results of regular diff since the latter is just # more readable diff --git a/cmake/macros/macro_deal_ii_initialize_cached_variables.cmake b/cmake/macros/macro_deal_ii_initialize_cached_variables.cmake index b695545e0d..9292456904 100644 --- a/cmake/macros/macro_deal_ii_initialize_cached_variables.cmake +++ b/cmake/macros/macro_deal_ii_initialize_cached_variables.cmake @@ -1,6 +1,6 @@ ## --------------------------------------------------------------------- ## -## Copyright (C) 2012 - 2014 by the deal.II authors +## Copyright (C) 2012 - 2015 by the deal.II authors ## ## This file is part of the deal.II library. ## @@ -54,10 +54,8 @@ MACRO(DEAL_II_INITIALIZE_CACHED_VARIABLES) # equal to Debug or Release or unsupported by the current build type: # STRING(TOLOWER "${CMAKE_BUILD_TYPE}" _cmake_build_type) - STRING(TOLOWER "${DEAL_II_BUILD_TYPE}" _deal_ii_build_type) - IF( NOT "${_cmake_build_type}" MATCHES "^(debug|release)$" - OR NOT _deal_ii_build_type MATCHES "${_cmake_build_type}" ) + IF(NOT "${_cmake_build_type}" MATCHES "^(debug|release|debugrelease)$") IF("${DEAL_II_BUILD_TYPE}" STREQUAL "DebugRelease") SET(_new_build_type "Debug") @@ -81,6 +79,7 @@ MACRO(DEAL_II_INITIALIZE_CACHED_VARIABLES) "Choose the type of build, options are: Debug, Release" FORCE ) + ENDIF() diff --git a/tests/setup_testsubproject.cmake b/tests/setup_testsubproject.cmake index ca24918939..f002a68c9b 100644 --- a/tests/setup_testsubproject.cmake +++ b/tests/setup_testsubproject.cmake @@ -1,5 +1,7 @@ FIND_PACKAGE(deal.II 8.0 REQUIRED HINTS ${DEAL_II_DIR}) -SET(CMAKE_CXX_COMPILER ${DEAL_II_CXX_COMPILER} CACHE STRING "CXX Compiler.") + +SET(CMAKE_BUILD_TYPE DebugRelease) +DEAL_II_INITIALIZE_CACHED_VARIABLES() # # Silence warnings: -- 2.39.5