CTestTargets.cmake 3.09 KB
Newer Older
1 2
# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
3 4


5
if(NOT RUN_FROM_CTEST_OR_DART)
Luz Paz's avatar
Luz Paz committed
6
  message(FATAL_ERROR "Do not include CTestTargets.cmake directly")
7
endif()
Andy Cedilnik's avatar
Andy Cedilnik committed
8

9 10 11 12
if(NOT PROJECT_BINARY_DIR)
  message(FATAL_ERROR "Do not include(CTest) before calling project().")
endif()

Andy Cedilnik's avatar
Andy Cedilnik committed
13
# make directories in the binary tree
14 15 16 17 18
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/Testing/Temporary)
get_filename_component(CMAKE_HOST_PATH ${CMAKE_COMMAND} PATH)
set(CMAKE_TARGET_PATH ${EXECUTABLE_OUTPUT_PATH})
find_program(CMAKE_CTEST_COMMAND ctest ${CMAKE_HOST_PATH} ${CMAKE_TARGET_PATH})
mark_as_advanced(CMAKE_CTEST_COMMAND)
Andy Cedilnik's avatar
Andy Cedilnik committed
19 20 21 22

# Use CTest
# configure files

23 24
if(CTEST_NEW_FORMAT)
  configure_file(
Andy Cedilnik's avatar
Andy Cedilnik committed
25 26
    ${CMAKE_ROOT}/Modules/DartConfiguration.tcl.in
    ${PROJECT_BINARY_DIR}/CTestConfiguration.ini )
27
else()
28
  configure_file(
Andy Cedilnik's avatar
Andy Cedilnik committed
29 30
    ${CMAKE_ROOT}/Modules/DartConfiguration.tcl.in
    ${PROJECT_BINARY_DIR}/DartConfiguration.tcl )
31
endif()
Andy Cedilnik's avatar
Andy Cedilnik committed
32 33 34 35 36 37 38 39

#
# Section 3:
#
# Custom targets to perform dashboard builds and submissions.
# These should NOT need to be modified from project to project.
#

40
set(__conf_types "")
41 42
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(_isMultiConfig)
43
  # We need to pass the configuration type on the test command line.
44
  set(__conf_types -C "${CMAKE_CFG_INTDIR}")
45
endif()
46

47 48
# Add convenience targets.  Do this at most once in case of nested
# projects.
49
define_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED
50 51 52
  BRIEF_DOCS "Internal property used by CTestTargets module."
  FULL_DOCS "Set by the CTestTargets module to track addition of testing targets."
  )
53 54 55
get_property(_CTEST_TARGETS_ADDED GLOBAL PROPERTY CTEST_TARGETS_ADDED)
if(NOT _CTEST_TARGETS_ADDED)
  set_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED 1)
Andy Cedilnik's avatar
Andy Cedilnik committed
56

57
  # For all generators add basic testing targets.
58 59
  foreach(mode Experimental Nightly Continuous NightlyMemoryCheck)
    add_custom_target(${mode}
60
      ${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode}
61
      USES_TERMINAL
62
      )
63 64
    set_property(TARGET ${mode} PROPERTY RULE_LAUNCH_CUSTOM "")
    set_property(TARGET ${mode} PROPERTY FOLDER "CTestDashboardTargets")
65
  endforeach()
Andy Cedilnik's avatar
Andy Cedilnik committed
66

67
  # For Makefile generators add more granular targets.
68
  if("${CMAKE_GENERATOR}" MATCHES "(Ninja|Make)")
69
    # Make targets for Experimental builds
70 71
    foreach(mode Nightly Experimental Continuous)
      foreach(testtype
72 73 74
          Start Update Configure Build Test Coverage MemCheck Submit
          # missing purify
          )
75
        add_custom_target(${mode}${testtype}
76
          ${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode}${testtype}
77
          USES_TERMINAL
78
          )
79 80
        set_property(TARGET ${mode}${testtype} PROPERTY RULE_LAUNCH_CUSTOM "")
        set_property(TARGET ${mode}${testtype} PROPERTY FOLDER "CTestDashboardTargets")
81 82 83
      endforeach()
    endforeach()
  endif()
84 85 86

  # If requested, add an alias that is the equivalent of the built-in "test"
  # or "RUN_TESTS" target:
87 88
  if(CTEST_TEST_TARGET_ALIAS)
    add_custom_target(${CTEST_TEST_TARGET_ALIAS}
89
      ${CMAKE_CTEST_COMMAND} ${__conf_types}
90
      USES_TERMINAL
91
      )
92
  endif()
93
endif()