From 55ec2c99785452e93b52033c3744d2f86aaff2ae Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Wed, 21 Mar 2018 10:20:03 -0500 Subject: [PATCH] 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. --- cmake/macros/macro_deal_ii_add_test.cmake | 29 +++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) 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() -- 2.39.5