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