From: Matthias Maier Date: Wed, 21 Mar 2018 15:20:03 +0000 (-0500) Subject: CMakes: Preprocess testsuite parameter files X-Git-Tag: v9.0.0-rc1~281^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=55ec2c99785452e93b52033c3744d2f86aaff2ae;p=dealii.git CMakes: Preprocess testsuite parameter files Add a third test variant consisting of a .prm.in file: test.output test.prm.in The test.prm.in file is preprocessed by CONFIGURE_FEATURE to a test.prm file substituting all @VARIABLE@ string with the corresponding CMake variable. --- diff --git a/cmake/macros/macro_deal_ii_add_test.cmake b/cmake/macros/macro_deal_ii_add_test.cmake index 5dbb375df6..bcfd45b741 100644 --- a/cmake/macros/macro_deal_ii_add_test.cmake +++ b/cmake/macros/macro_deal_ii_add_test.cmake @@ -38,6 +38,14 @@ # TEST_TARGET or # TEST_TARGET_DEBUG and TEST_TARGET_RELEASE # +# - If the parameter file in the second test variant is named +# "${test_name}.prm.in" it will be configured/preprocessed to a +# "${test_name}.prm" file. This preprocessing is done with the CMake +# macro CONFIGURE_FILE that replaces all strings @VARIABLE@ with the +# contents of the corresponding CMake variable. This is useful in +# particular to conveniently substitute @SOURCE_DIR@ with the full source +# directory path of the test. +# # 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. @@ -180,7 +188,20 @@ MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file) SET(_target ${_test_name}.${_build_lowercase}) # target name SET(_run_args "$") # the command to issue - ELSEIF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_test_name}.prm") + ELSEIF( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_test_name}.prm" OR + EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_test_name}.prm.in" ) + + IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_test_name}.prm.in") + SET(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + CONFIGURE_FILE( + "${CMAKE_CURRENT_SOURCE_DIR}/${_test_name}.prm.in" + "${CMAKE_CURRENT_BINARY_DIR}/${_test_name}.prm" + @ONLY + ) + SET(_prm_file "${CMAKE_CURRENT_BINARY_DIR}/${_test_name}.prm") + ELSE() + SET(_prm_file "${CMAKE_CURRENT_SOURCE_DIR}/${_test_name}.prm") + ENDIF() IF(NOT "${TEST_TARGET_${_build}}" STREQUAL "") SET(_target ${TEST_TARGET_${_build}}) @@ -188,14 +209,14 @@ MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file) SET(_target ${TEST_TARGET}) ELSE() MESSAGE(FATAL_ERROR - "\nFor ${_comparison_file}: \"${_test_name}.prm\" provided, but " - "neither \"\${TEST_TARGET}\", nor \"\${TEST_TARGET_${_build}}" + "\nFor ${_comparison_file}: \"${_test_name}.prm(.in)\" provided, " + "but neither \"\${TEST_TARGET}\", nor \"\${TEST_TARGET_${_build}}" "\" is defined.\n\n" ) ENDIF() SET(_run_args "$" - "${CMAKE_CURRENT_SOURCE_DIR}/${_test_name}.prm" + "${_prm_file}" ) ELSE()