summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/RunCTest.cmake
blob: 87d17f254e07e33f746e56c21f17664d1c8bce4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.

include(RunCMake)

# Isolate our ctest runs from external environment.
unset(ENV{CTEST_PARALLEL_LEVEL})
unset(ENV{CTEST_OUTPUT_ON_FAILURE})
unset(ENV{CTEST_NO_TESTS_ACTION})

function(run_ctest CASE_NAME)
  configure_file(${RunCMake_SOURCE_DIR}/test.cmake.in
                 ${RunCMake_BINARY_DIR}/${CASE_NAME}/test.cmake @ONLY)
  if(EXISTS "${RunCMake_SOURCE_DIR}/CTestConfig.cmake.in")
    configure_file(${RunCMake_SOURCE_DIR}/CTestConfig.cmake.in
                   ${RunCMake_BINARY_DIR}/${CASE_NAME}/CTestConfig.cmake @ONLY)
  else()
    file(REMOVE ${RunCMake_BINARY_DIR}/${CASE_NAME}/CTestConfig.cmake)
  endif()
  configure_file(${RunCMake_SOURCE_DIR}/CMakeLists.txt.in
                 ${RunCMake_BINARY_DIR}/${CASE_NAME}/CMakeLists.txt @ONLY)
  if(NOT DEFINED RunCTest_VERBOSE_FLAG)
    set(RunCTest_VERBOSE_FLAG "-V")
  endif()
  run_cmake_command(${CASE_NAME} ${CMAKE_CTEST_COMMAND}
    -C Debug
    -S ${RunCMake_BINARY_DIR}/${CASE_NAME}/test.cmake
    ${RunCTest_VERBOSE_FLAG}
    --output-log ${RunCMake_BINARY_DIR}/${CASE_NAME}-build/testOutput.log
    --no-compress-output
    ${ARGN}
    )
endfunction()