forked from commontk/CTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathctkDashboardDriverScript.cmake
251 lines (211 loc) · 7.87 KB
/
ctkDashboardDriverScript.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
###########################################################################
#
# Library: CTK
#
# Copyright (c) 2010 Kitware Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.commontk.org/LICENSE
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
###########################################################################
#
# Included from a dashboard script, this cmake file will drive the configure and build
# steps of the different CTK sub-project (library, application or plugins)
#
# The following variable are expected to be define in the top-level script:
set(expected_variables
ADDITIONNAL_CMAKECACHE_OPTION
CTEST_NOTES_FILES
CTEST_SITE
CTEST_DASHBOARD_ROOT
CTEST_CMAKE_COMMAND
CTEST_CMAKE_GENERATOR
WITH_MEMCHECK
WITH_COVERAGE
WITH_DOCUMENTATION
CTEST_BUILD_CONFIGURATION
CTEST_TEST_TIMEOUT
CTEST_BUILD_FLAGS
TEST_TO_EXCLUDE_REGEX
CTEST_PROJECT_NAME
CTEST_SOURCE_DIRECTORY
CTEST_BINARY_DIRECTORY
CTEST_BUILD_NAME
SCRIPT_MODE
CTEST_COVERAGE_COMMAND
CTEST_MEMORYCHECK_COMMAND
CTEST_GIT_COMMAND
QT_QMAKE_EXECUTABLE
)
if(WITH_DOCUMENTATION)
list(APPEND expected_variables DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY)
endif()
foreach(var ${expected_variables})
if(NOT DEFINED ${var})
message(FATAL_ERROR "Variable ${var} should be defined in top-level script !")
endif()
endforeach()
# Should binary directory be cleaned?
set(empty_binary_directory FALSE)
# Attempt to build and test also if 'ctest_update' returned an error
set(force_build FALSE)
set(model "")
if (SCRIPT_MODE STREQUAL "experimental")
set(empty_binary_directory FALSE)
set(force_build TRUE)
set(model Experimental)
elseif (SCRIPT_MODE STREQUAL "continuous")
set(empty_binary_directory TRUE)
set(force_build FALSE)
set(model Continuous)
elseif (SCRIPT_MODE STREQUAL "nightly")
set(empty_binary_directory TRUE)
set(force_build TRUE)
set(model Nightly)
else()
message(FATAL_ERROR "Unknown script mode: '${SCRIPT_MODE}'. Script mode should be either 'experimental', 'continuous' or 'nightly'")
endif()
#message("script_mode:${SCRIPT_MODE}")
#message("model:${model}")
#message("empty_binary_directory:${empty_binary_directory}")
#message("force_build:${force_build}")
set(CTEST_USE_LAUNCHERS 1)
if(empty_binary_directory)
message("Directory ${CTEST_BINARY_DIRECTORY} cleaned !")
ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY})
endif()
if(NOT EXISTS "${CTEST_SOURCE_DIRECTORY}")
set(CTEST_CHECKOUT_COMMAND "${CTEST_GIT_COMMAND} clone http://github.com/pieper/CTK.git ${CTEST_SOURCE_DIRECTORY}")
endif()
set(CTEST_UPDATE_COMMAND "${CTEST_GIT_COMMAND}")
#
# run_ctest macro
#
MACRO(run_ctest)
ctest_start(${model})
ctest_update(SOURCE "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res)
#ctest_submit(PARTS Update Notes)
# force a build if this is the first run and the build dir is empty
if(NOT EXISTS "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt")
message("First time build - Initialize CMakeCache.txt")
set(res 1)
# Write initial cache.
file(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" "
CTEST_USE_LAUNCHERS:BOOL=${CTEST_USE_LAUNCHERS}
QT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
SUPERBUILD_EXCLUDE_CTKBUILD_TARGET:BOOL=TRUE
WITH_COVERAGE:BOOL=${WITH_COVERAGE}
DOCUMENTATION_TARGET_IN_ALL:BOOL=${WITH_DOCUMENTATION}
DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY:PATH=${DOCUMENTATION_ARCHIVES_OUTPUT_DIRECTORY}
${ADDITIONNAL_CMAKECACHE_OPTION}
")
endif()
if (res GREATER 0 OR force_build)
message("Configure SuperBuild")
set_property(GLOBAL PROPERTY SubProject SuperBuild)
set_property(GLOBAL PROPERTY Label SuperBuild)
ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}")
ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}")
ctest_submit(PARTS Configure)
ctest_submit(FILES "${CTEST_BINARY_DIRECTORY}/Project.xml")
# Build top level
message("Build SuperBuild")
ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}" APPEND)
ctest_submit(PARTS Build)
ctest_test(
BUILD "${CTEST_BINARY_DIRECTORY}"
INCLUDE_LABEL "SuperBuild"
PARALLEL_LEVEL 8
EXCLUDE ${TEST_TO_EXCLUDE_REGEX})
# runs only tests that have a LABELS property matching "${subproject}"
ctest_submit(PARTS Test)
set(ctk_build_dir "${CTEST_BINARY_DIRECTORY}/CTK-build")
# To get CTEST_PROJECT_SUBPROJECTS definition
include("${CTEST_BINARY_DIRECTORY}/CTestConfigSubProject.cmake")
set(kit_suffixes
CppTests
#PythonTests
Plugins
)
foreach(subproject ${CTEST_PROJECT_SUBPROJECTS})
set_property(GLOBAL PROPERTY SubProject ${subproject})
set_property(GLOBAL PROPERTY Label ${subproject})
message("Build ${subproject}")
# Configure target
ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}")
ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}")
ctest_submit(PARTS Configure)
# Build target
set(CTEST_BUILD_TARGET "${subproject}")
ctest_build(BUILD "${ctk_build_dir}" APPEND)
# Loop over kit suffixes and try to build the corresponding target
foreach(kit_suffixe ${kit_suffixes})
message("Build ${subproject}${kit_suffixe}")
set(CTEST_BUILD_TARGET "${subproject}${kit_suffixe}")
ctest_build(BUILD "${ctk_build_dir}" APPEND)
endforeach()
ctest_submit(PARTS Build)
endforeach()
# HACK Unfortunately ctest_coverage ignores the build argument, try to force it...
file(READ ${ctk_build_dir}/CMakeFiles/TargetDirectories.txt ctk_build_coverage_dirs)
file(APPEND "${CTEST_BINARY_DIRECTORY}/CMakeFiles/TargetDirectories.txt" "${ctk_build_coverage_dirs}")
foreach(subproject ${CTEST_PROJECT_SUBPROJECTS})
set_property(GLOBAL PROPERTY SubProject ${subproject})
set_property(GLOBAL PROPERTY Label ${subproject})
message("Test ${subproject}")
ctest_test(
BUILD "${ctk_build_dir}"
INCLUDE_LABEL "${subproject}"
PARALLEL_LEVEL 8
EXCLUDE ${test_to_exclude_regex})
# runs only tests that have a LABELS property matching "${subproject}"
ctest_submit(PARTS Test)
# Coverage per sub-project (library, application or plugin)
if (WITH_COVERAGE AND CTEST_COVERAGE_COMMAND)
message("Coverage ${subproject}")
ctest_coverage(BUILD "${ctk_build_dir}" LABELS "${subproject}")
ctest_submit(PARTS Coverage)
endif ()
#if (WITH_MEMCHECK AND CTEST_MEMORYCHECK_COMMAND)
# ctest_memcheck(BUILD "${ctk_build_dir}" INCLUDE_LABEL "${subproject}")
# ctest_submit(PARTS MemCheck)
#endif ()
endforeach()
set_property(GLOBAL PROPERTY SubProject SuperBuild)
set_property(GLOBAL PROPERTY Label SuperBuild)
# Global coverage ...
if (WITH_COVERAGE AND CTEST_COVERAGE_COMMAND)
message("Global coverage")
ctest_coverage(BUILD "${ctk_build_dir}")
ctest_submit(PARTS Coverage)
endif ()
# Global dynamic analysis ...
if (WITH_MEMCHECK AND CTEST_MEMORYCHECK_COMMAND)
message("Global memcheck")
ctest_memcheck(BUILD "${ctk_build_dir}")
ctest_submit(PARTS MemCheck)
endif ()
# Note should be at the end
ctest_submit(PARTS Notes)
endif()
endmacro()
if(SCRIPT_MODE STREQUAL "continuous")
while(${CTEST_ELAPSED_TIME} LESS 68400)
set(START_TIME ${CTEST_ELAPSED_TIME})
run_ctest()
# Loop no faster than once every 5 minutes
message("Wait for 5 minutes ...")
ctest_sleep(${START_TIME} 300 ${CTEST_ELAPSED_TIME})
endwhile()
else()
run_ctest()
endif()