1# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2# file Copyright.txt or https://cmake.org/licensing for details.
3
4
5if(NOT RUN_FROM_CTEST_OR_DART)
6  message(FATAL_ERROR "Do not include CTestTargets.cmake directly")
7endif()
8
9if(NOT PROJECT_BINARY_DIR)
10  message(FATAL_ERROR "Do not include(CTest) before calling project().")
11endif()
12
13# make directories in the binary tree
14file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/Testing/Temporary)
15get_filename_component(CMAKE_HOST_PATH ${CMAKE_COMMAND} PATH)
16set(CMAKE_TARGET_PATH ${EXECUTABLE_OUTPUT_PATH})
17find_program(CMAKE_CTEST_COMMAND ctest ${CMAKE_HOST_PATH} ${CMAKE_TARGET_PATH})
18mark_as_advanced(CMAKE_CTEST_COMMAND)
19
20# Use CTest
21# configure files
22
23if(CTEST_NEW_FORMAT)
24  configure_file(
25    ${CMAKE_ROOT}/Modules/DartConfiguration.tcl.in
26    ${PROJECT_BINARY_DIR}/CTestConfiguration.ini )
27else()
28  configure_file(
29    ${CMAKE_ROOT}/Modules/DartConfiguration.tcl.in
30    ${PROJECT_BINARY_DIR}/DartConfiguration.tcl )
31endif()
32
33#
34# Section 3:
35#
36# Custom targets to perform dashboard builds and submissions.
37# These should NOT need to be modified from project to project.
38#
39
40set(__conf_types "")
41get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
42if(_isMultiConfig)
43  # We need to pass the configuration type on the test command line.
44  set(__conf_types -C "${CMAKE_CFG_INTDIR}")
45endif()
46
47# Add convenience targets.  Do this at most once in case of nested
48# projects.
49define_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED
50  BRIEF_DOCS "Internal property used by CTestTargets module."
51  FULL_DOCS "Set by the CTestTargets module to track addition of testing targets."
52  )
53get_property(_CTEST_TARGETS_ADDED GLOBAL PROPERTY CTEST_TARGETS_ADDED)
54if(NOT _CTEST_TARGETS_ADDED)
55  set_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED 1)
56
57  # For all generators add basic testing targets.
58  foreach(mode Experimental Nightly Continuous NightlyMemoryCheck)
59    add_custom_target(${mode}
60      ${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode}
61      USES_TERMINAL
62      )
63    set_property(TARGET ${mode} PROPERTY RULE_LAUNCH_CUSTOM "")
64    set_property(TARGET ${mode} PROPERTY FOLDER "CTestDashboardTargets")
65  endforeach()
66
67  # For Makefile generators add more granular targets.
68  if("${CMAKE_GENERATOR}" MATCHES "(Ninja|Make)")
69    # Make targets for Experimental builds
70    foreach(mode Nightly Experimental Continuous)
71      foreach(testtype
72          Start Update Configure Build Test Coverage MemCheck Submit
73          # missing purify
74          )
75        add_custom_target(${mode}${testtype}
76          ${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode}${testtype}
77          USES_TERMINAL
78          )
79        set_property(TARGET ${mode}${testtype} PROPERTY RULE_LAUNCH_CUSTOM "")
80        set_property(TARGET ${mode}${testtype} PROPERTY FOLDER "CTestDashboardTargets")
81      endforeach()
82    endforeach()
83  endif()
84
85  # If requested, add an alias that is the equivalent of the built-in "test"
86  # or "RUN_TESTS" target:
87  if(CTEST_TEST_TARGET_ALIAS)
88    add_custom_target(${CTEST_TEST_TARGET_ALIAS}
89      ${CMAKE_CTEST_COMMAND} ${__conf_types}
90      USES_TERMINAL
91      )
92  endif()
93endif()
94