CTestTargets.cmake 3.49 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11

#=============================================================================
# Copyright 2005-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
12
# (To distribute this file outside of CMake, substitute the full
13 14
#  License text for the above reference.)

15 16
if(NOT RUN_FROM_CTEST_OR_DART)
  message(FATAL_ERROR "Do not incldue CTestTargets.cmake directly")
17
endif()
Andy Cedilnik's avatar
Andy Cedilnik committed
18

19 20 21 22
if(NOT PROJECT_BINARY_DIR)
  message(FATAL_ERROR "Do not include(CTest) before calling project().")
endif()

Andy Cedilnik's avatar
Andy Cedilnik committed
23
# make directories in the binary tree
24 25 26 27 28
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
29 30 31 32

# Use CTest
# configure files

33 34
if(CTEST_NEW_FORMAT)
  configure_file(
Andy Cedilnik's avatar
Andy Cedilnik committed
35 36
    ${CMAKE_ROOT}/Modules/DartConfiguration.tcl.in
    ${PROJECT_BINARY_DIR}/CTestConfiguration.ini )
37
else()
38
  configure_file(
Andy Cedilnik's avatar
Andy Cedilnik committed
39 40
    ${CMAKE_ROOT}/Modules/DartConfiguration.tcl.in
    ${PROJECT_BINARY_DIR}/DartConfiguration.tcl )
41
endif()
Andy Cedilnik's avatar
Andy Cedilnik committed
42 43 44 45 46 47 48 49

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

50 51
set(__conf_types "")
if(CMAKE_CONFIGURATION_TYPES)
52
  # We need to pass the configuration type on the test command line.
53
  set(__conf_types -C "${CMAKE_CFG_INTDIR}")
54
endif()
55

56 57
# Add convenience targets.  Do this at most once in case of nested
# projects.
58
define_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED
59 60 61
  BRIEF_DOCS "Internal property used by CTestTargets module."
  FULL_DOCS "Set by the CTestTargets module to track addition of testing targets."
  )
62 63 64
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
65

66
  # For all generators add basic testing targets.
67 68
  foreach(mode Experimental Nightly Continuous NightlyMemoryCheck)
    add_custom_target(${mode}
69
      ${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode}
70
      USES_TERMINAL
71
      )
72 73
    set_property(TARGET ${mode} PROPERTY RULE_LAUNCH_CUSTOM "")
    set_property(TARGET ${mode} PROPERTY FOLDER "CTestDashboardTargets")
74
  endforeach()
Andy Cedilnik's avatar
Andy Cedilnik committed
75

76
  # For Makefile generators add more granular targets.
77
  if("${CMAKE_GENERATOR}" MATCHES "(Ninja|Make)")
78
    # Make targets for Experimental builds
79 80
    foreach(mode Nightly Experimental Continuous)
      foreach(testtype
81 82 83
          Start Update Configure Build Test Coverage MemCheck Submit
          # missing purify
          )
84
        add_custom_target(${mode}${testtype}
85
          ${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode}${testtype}
86
          USES_TERMINAL
87
          )
88 89
        set_property(TARGET ${mode}${testtype} PROPERTY RULE_LAUNCH_CUSTOM "")
        set_property(TARGET ${mode}${testtype} PROPERTY FOLDER "CTestDashboardTargets")
90 91 92
      endforeach()
    endforeach()
  endif()
93 94 95

  # If requested, add an alias that is the equivalent of the built-in "test"
  # or "RUN_TESTS" target:
96 97
  if(CTEST_TEST_TARGET_ALIAS)
    add_custom_target(${CTEST_TEST_TARGET_ALIAS}
98
      ${CMAKE_CTEST_COMMAND} ${__conf_types}
99
      USES_TERMINAL
100
      )
101
  endif()
102
endif()