1 # - Configure a project for testing with CTest/CDash
2 # This file configures a project to use the CTest/CDash/Dart
3 # testing/dashboard process. This module should be included
4 # in the CMakeLists.txt file at the top of a project. Typical usage:
7 # # ... testing related CMake code ...
9 # The BUILD_TESTING option is created by the CTest module to determine
10 # whether testing support should be enabled. The default is ON.
12 OPTION(BUILD_TESTING "Build the testing tree." ON)
14 # function to turn generator name into a version string
15 # like vs7 vs71 vs8 vs9
16 FUNCTION(GET_VS_VERSION_STRING generator var)
17 STRING(REGEX REPLACE "Visual Studio ([0-9][0-9]?)($|.*)" "\\1" NUMBER "${generator}")
18 IF("${generator}" MATCHES "Visual Studio 7 .NET 2003")
19 SET(ver_string "vs71")
20 ELSE("${generator}" MATCHES "Visual Studio 7 .NET 2003")
21 SET(ver_string "vs${NUMBER}")
22 ENDIF("${generator}" MATCHES "Visual Studio 7 .NET 2003")
23 SET(${var} ${ver_string} PARENT_SCOPE)
24 ENDFUNCTION(GET_VS_VERSION_STRING)
27 # Setup some auxilary macros
28 MACRO(SET_IF_NOT_SET var val)
29 IF(NOT DEFINED "${var}")
30 SET("${var}" "${val}")
31 ENDIF(NOT DEFINED "${var}")
32 ENDMACRO(SET_IF_NOT_SET)
34 MACRO(SET_IF_SET var val)
35 IF(NOT "${val}" MATCHES "^$")
36 SET("${var}" "${val}")
37 ENDIF(NOT "${val}" MATCHES "^$")
40 MACRO(SET_IF_SET_AND_NOT_SET var val)
41 IF(NOT "${val}" MATCHES "^$")
42 SET_IF_NOT_SET("${var}" "${val}")
43 ENDIF(NOT "${val}" MATCHES "^$")
44 ENDMACRO(SET_IF_SET_AND_NOT_SET)
46 # Make sure testing is enabled
49 IF(EXISTS "${PROJECT_SOURCE_DIR}/CTestConfig.cmake")
50 INCLUDE("${PROJECT_SOURCE_DIR}/CTestConfig.cmake")
51 SET_IF_SET_AND_NOT_SET(NIGHTLY_START_TIME "${CTEST_NIGHTLY_START_TIME}")
52 SET_IF_SET_AND_NOT_SET(DROP_METHOD "${CTEST_DROP_METHOD}")
53 SET_IF_SET_AND_NOT_SET(DROP_SITE "${CTEST_DROP_SITE}")
54 SET_IF_SET_AND_NOT_SET(DROP_SITE_USER "${CTEST_DROP_SITE_USER}")
55 SET_IF_SET_AND_NOT_SET(DROP_SITE_PASSWORD "${CTEST_DROP_SITE_PASWORD}")
56 SET_IF_SET_AND_NOT_SET(DROP_SITE_MODE "${CTEST_DROP_SITE_MODE}")
57 SET_IF_SET_AND_NOT_SET(DROP_LOCATION "${CTEST_DROP_LOCATION}")
58 SET_IF_SET_AND_NOT_SET(TRIGGER_SITE "${CTEST_TRIGGER_SITE}")
59 SET_IF_SET_AND_NOT_SET(UPDATE_TYPE "${CTEST_UPDATE_TYPE}")
60 ENDIF(EXISTS "${PROJECT_SOURCE_DIR}/CTestConfig.cmake")
62 # the project can have a DartConfig.cmake file
63 IF(EXISTS "${PROJECT_SOURCE_DIR}/DartConfig.cmake")
64 INCLUDE("${PROJECT_SOURCE_DIR}/DartConfig.cmake")
65 ELSE(EXISTS "${PROJECT_SOURCE_DIR}/DartConfig.cmake")
67 # Dashboard is opened for submissions for a 24 hour period starting at
68 # the specified NIGHTLY_START_TIME. Time is specified in 24 hour format.
69 SET_IF_NOT_SET (NIGHTLY_START_TIME "00:00:00 EDT")
70 SET_IF_NOT_SET(DROP_METHOD "http")
72 # Dart server to submit results (used by client)
73 # There should be an option to specify submit method, but I will leave it
74 # commented until we decide what to do with it.
75 # SET(DROP_METHOD "http" CACHE STRING "Set the CTest submit method. Valid options are http and ftp")
76 IF(DROP_METHOD MATCHES http)
77 SET_IF_NOT_SET (DROP_SITE "public.kitware.com")
78 SET_IF_NOT_SET (DROP_LOCATION "/cgi-bin/HTTPUploadDartFile.cgi")
79 ELSE(DROP_METHOD MATCHES http)
80 SET_IF_NOT_SET (DROP_SITE "public.kitware.com")
81 SET_IF_NOT_SET (DROP_LOCATION "/incoming")
82 SET_IF_NOT_SET (DROP_SITE_USER "anonymous")
83 SET_IF_NOT_SET (DROP_SITE_PASSWORD "random@someplace.com")
84 SET_IF_NOT_SET (DROP_SITE_MODE "active")
85 ENDIF(DROP_METHOD MATCHES http)
86 SET_IF_NOT_SET (TRIGGER_SITE "http://${DROP_SITE}/cgi-bin/Submit-Random-TestingResults.cgi")
87 SET_IF_NOT_SET (COMPRESS_SUBMISSION ON)
89 # Dart server configuration
90 SET (ROLLUP_URL "http://${DROP_SITE}/cgi-bin/random-rollup-dashboard.sh")
92 #SET (CVS_WEB_CVSROOT "")
94 #SET (USE_DOXYGEN "Off")
95 #SET (DOXYGEN_URL "" )
96 ENDIF(EXISTS "${PROJECT_SOURCE_DIR}/DartConfig.cmake")
97 SET_IF_NOT_SET (NIGHTLY_START_TIME "00:00:00 EDT")
99 # make program just needs to use CMAKE_MAKE_PROGRAM which is required
100 # to be defined by cmake
101 SET(MAKEPROGRAM ${CMAKE_MAKE_PROGRAM})
103 FIND_PROGRAM(CVSCOMMAND cvs )
104 SET(CVS_UPDATE_OPTIONS "-d -A -P" CACHE STRING
105 "Options passed to the cvs update command.")
106 FIND_PROGRAM(SVNCOMMAND svn)
109 IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/CVS")
111 ELSE(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/CVS")
112 IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.svn")
114 ENDIF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.svn")
115 ENDIF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/CVS")
116 ENDIF(NOT UPDATE_TYPE)
119 IF(NOT __CTEST_UPDATE_TYPE_COMPLAINED)
120 SET(__CTEST_UPDATE_TYPE_COMPLAINED 1 CACHE INTERNAL "Already complained about update type.")
121 MESSAGE(STATUS "CTest cannot determine repository type. Please set UPDATE_TYPE to 'cvs' or 'svn'. CTest update will not work.")
122 ENDIF(NOT __CTEST_UPDATE_TYPE_COMPLAINED)
123 ENDIF(NOT UPDATE_TYPE)
125 IF(UPDATE_TYPE MATCHES "[Cc][Vv][Ss]")
126 SET(UPDATE_COMMAND "${CVSCOMMAND}")
127 SET(UPDATE_OPTIONS "${CVS_UPDATE_OPTIONS}")
128 ELSE(UPDATE_TYPE MATCHES "[Cc][Vv][Ss]")
129 IF(UPDATE_TYPE MATCHES "[Ss][Vv][Nn]")
130 SET(UPDATE_COMMAND "${SVNCOMMAND}")
131 SET(UPDATE_OPTIONS "${SVN_UPDATE_OPTIONS}")
132 ENDIF(UPDATE_TYPE MATCHES "[Ss][Vv][Nn]")
133 ENDIF(UPDATE_TYPE MATCHES "[Cc][Vv][Ss]")
135 SET(DART_TESTING_TIMEOUT 1500 CACHE STRING
136 "Maximum time allowed before CTest will kill the test.")
138 FIND_PROGRAM(MEMORYCHECK_COMMAND
139 NAMES purify valgrind boundscheck
141 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Rational Software\\Purify\\Setup;InstallFolder]"
142 DOC "Path to the memory checking command, used for memory error detection."
144 SET(MEMORYCHECK_SUPPRESSIONS_FILE "" CACHE FILEPATH
145 "File that contains suppressions for the memory checker")
146 FIND_PROGRAM(SCPCOMMAND scp DOC
147 "Path to scp command, used by CTest for submitting results to a Dart server"
149 FIND_PROGRAM(COVERAGE_COMMAND gcov DOC
150 "Path to the coverage program that CTest uses for performing coverage inspection"
157 SET(DART_COMPILER "${CMAKE_CXX_COMPILER}")
158 IF(NOT DART_COMPILER)
159 SET(DART_COMPILER "${CMAKE_C_COMPILER}")
160 ENDIF(NOT DART_COMPILER)
161 IF(NOT DART_COMPILER)
162 SET(DART_COMPILER "unknown")
163 ENDIF(NOT DART_COMPILER)
165 SET(DART_NAME_COMPONENT "NAME_WE")
167 SET(DART_NAME_COMPONENT "NAME")
169 IF(NOT BUILD_NAME_SYSTEM_NAME)
170 SET(BUILD_NAME_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}")
171 ENDIF(NOT BUILD_NAME_SYSTEM_NAME)
173 SET(BUILD_NAME_SYSTEM_NAME "Win32")
176 GET_FILENAME_COMPONENT(DART_CXX_NAME
177 "${CMAKE_CXX_COMPILER}" ${DART_NAME_COMPONENT})
178 ELSE(UNIX OR BORLAND)
179 GET_FILENAME_COMPONENT(DART_CXX_NAME
180 "${CMAKE_BUILD_TOOL}" ${DART_NAME_COMPONENT})
181 ENDIF(UNIX OR BORLAND)
182 IF(DART_CXX_NAME MATCHES "msdev")
183 SET(DART_CXX_NAME "vs60")
184 ENDIF(DART_CXX_NAME MATCHES "msdev")
185 IF(DART_CXX_NAME MATCHES "devenv")
186 GET_VS_VERSION_STRING("${CMAKE_GENERATOR}" DART_CXX_NAME)
187 ENDIF(DART_CXX_NAME MATCHES "devenv")
188 SET(BUILDNAME "${BUILD_NAME_SYSTEM_NAME}-${DART_CXX_NAME}")
190 # set the build command
191 BUILD_COMMAND(MAKECOMMAND ${MAKEPROGRAM} )
193 IF(NOT "${CMAKE_GENERATOR}" MATCHES "Make")
194 SET(CTEST_USE_LAUNCHERS 0)
195 ENDIF(NOT "${CMAKE_GENERATOR}" MATCHES "Make")
196 IF(CTEST_USE_LAUNCHERS)
197 SET(CTEST_LAUNCH_COMPILE "\"${CMAKE_CTEST_COMMAND}\" --launch --target-name <TARGET_NAME> --build-dir <CMAKE_CURRENT_BINARY_DIR> --output <OBJECT> --source <SOURCE> --language <LANGUAGE> --")
198 SET(CTEST_LAUNCH_LINK "\"${CMAKE_CTEST_COMMAND}\" --launch --target-name <TARGET_NAME> --build-dir <CMAKE_CURRENT_BINARY_DIR> --output <TARGET> --target-type <TARGET_TYPE> --language <LANGUAGE> --")
199 SET(CTEST_LAUNCH_CUSTOM "\"${CMAKE_CTEST_COMMAND}\" --launch --target-name <TARGET_NAME> --build-dir <CMAKE_CURRENT_BINARY_DIR> --output <OUTPUT> --")
200 SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CTEST_LAUNCH_COMPILE}")
201 SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CTEST_LAUNCH_LINK}")
202 SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_CUSTOM "${CTEST_LAUNCH_CUSTOM}")
203 ENDIF(CTEST_USE_LAUNCHERS)
213 MEMORYCHECK_SUPPRESSIONS_FILE
219 IF(NOT RUN_FROM_DART)
220 SET(RUN_FROM_CTEST_OR_DART 1)
221 INCLUDE(CTestTargets)
222 SET(RUN_FROM_CTEST_OR_DART)
223 ENDIF(NOT RUN_FROM_DART)