-
Notifications
You must be signed in to change notification settings - Fork 3
/
vecgeom-ctest.cmake
164 lines (140 loc) · 5.65 KB
/
vecgeom-ctest.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
####################################################################
# Before run should be exported next variables:
# $CTEST_BUILD_OPTIONS // CMake flags for VecGeom build
# $CMAKE_SOURCE_DIR // CMake source directory
# $CMAKE_BINARY_DIR // CMake binary directory
# $CMAKE_BUILD_TYPE // CMake build type: Debug, Release
# $CMAKE_INSTALL_PREFIX // Installation prefix for CMake (Jenkins trigger)
# CC and CXX (In Jenkins this step has been done authomaticly)
# Enviroment for name of build for CERN CDash:
# $LABEL // Name of node (Jenkins trigger)
# Name of $BACKEND // Backend for VecGeom (CUDA/Vc/Scalar/..)
cmake_minimum_required(VERSION 2.8)
###################################################################
macro(CheckExitCode)
if(NOT ${ExitCode} EQUAL 0)
return(${ExitCode})
endif()
endmacro(CheckExitCode)
####################################################################
# Build name settings
find_program(UNAME NAMES uname)
macro(getuname name flag)
exec_program("${UNAME}" ARGS "${flag}" OUTPUT_VARIABLE "${name}")
endmacro(getuname)
getuname(osname -s)
getuname(osrel -r)
getuname(cpu -m)
if(DEFINED ENV{LABEL})
if (DEFINED ENV{BACKEND})
set(CTEST_BUILD_NAME "${osname}-${cpu}-$ENV{LABEL}-$ENV{BACKEND}-$ENV{CMAKE_BUILD_TYPE}")
endif()
else()
set(CTEST_BUILD_NAME "${osname}-${cpu}-$ENV{LABEL}-$ENV{CMAKE_BUILD_TYPE}")
endif()
message("CTEST name: ${CTEST_BUILD_NAME}")
find_program(HOSTNAME_CMD NAMES hostname)
exec_program(${HOSTNAME_CMD} ARGS OUTPUT_VARIABLE HOSTNAME)
IF(NOT DEFINED CTEST_SITE)
SET(CTEST_SITE "${HOSTNAME}")
ENDIF(NOT DEFINED CTEST_SITE)
#######################################################
set(WITH_MEMCHECK FALSE)
set(WITH_COVERAGE FALSE)
set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE "5000")
set(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE "5000")
#######################################################
#set(CTEST_USE_LAUNCHERS 1)
#if(NOT "${CTEST_CMAKE_GENERATOR}" MATCHES "Make")
# set(CTEST_USE_LAUNCHERS 0)
#endif()
#set(ENV{CTEST_USE_LAUNCHERS_DEFAULT} ${CTEST_USE_LAUNCHERS})
######################################################
# CTest/CMake settings
set(CTEST_TEST_TIMEOUT 3600)
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_BUILD_TYPE}")
set(CMAKE_INSTALL_PREFIX "$ENV{CMAKE_INSTALL_PREFIX}")
set(CTEST_SOURCE_DIRECTORY "$ENV{CMAKE_SOURCE_DIR}")
set(CTEST_BINARY_DIRECTORY "$ENV{CMAKE_BINARY_DIR}")
set(CTEST_CMAKE_GENERATOR "Unix Makefiles")
set(CTEST_BUILD_OPTIONS "$ENV{CTEST_BUILD_OPTIONS}")
set(CTEST_CONFIGURE_COMMAND "\"${CMAKE_COMMAND}\" \"-G${CTEST_CMAKE_GENERATOR}\" -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_BUILD_TYPE=${CTEST_BUILD_CONFIGURATION} ${CTEST_BUILD_OPTIONS} ${CTEST_SOURCE_DIRECTORY}")
ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY})
#########################################################
# git command configuration
find_program(CTEST_GIT_COMMAND NAMES git)
if(NOT EXISTS "${CTEST_SOURCE_DIRECTORY}")
set(CTEST_CHECKOUT_COMMAND "${CTEST_GIT_COMMAND} clone http://git.cern.ch/pub/VecGeom ${CTEST_SOURCE_DIRECTORY}")
endif()
set(CTEST_GIT_UPDATE_COMMAND "${CTEST_GIT_COMMAND}")
if(NOT "$ENV{GIT_COMMIT}" STREQUAL "")
set(CTEST_CHECKOUT_COMMAND "cmake -E chdir ${CTEST_SOURCE_DIRECTORY} ${CTEST_GIT_COMMAND} checkout -f $ENV{GIT_PREVIOUS_COMMIT}")
set(CTEST_GIT_UPDATE_CUSTOM ${CTEST_GIT_COMMAND} checkout -f $ENV{GIT_COMMIT})
endif()
#########################################################
## Output language
set($ENV{LC_MESSAGES} "en_EN")
#########################################################
# Use multiple CPU cores to build
include(ProcessorCount)
ProcessorCount(N)
if(NOT N EQUAL 0)
if(NOT WIN32)
set(CTEST_BUILD_FLAGS -j${N})
endif(NOT WIN32)
set(ctest_test_args ${ctest_test_args} PARALLEL_LEVEL ${N})
endif()
##########################################################
# Print summary information.
foreach(v
CTEST_SITE
CTEST_BUILD_NAME
CTEST_SOURCE_DIRECTORY
CTEST_BINARY_DIRECTORY
CTEST_CMAKE_GENERATOR
CTEST_BUILD_CONFIGURATION
CTEST_GIT_COMMAND
CTEST_CONFIGURE_COMMAND
CTEST_SCRIPT_DIRECTORY
CTEST_BUILD_FLAGS
WITH_MEMCHECK
WITH_COVERAGE
)
set(vars "${vars} ${v}=[${${v}}]\n")
endforeach(v)
message("Dashboard script configuration (check if everything is declared correctly):\n${vars}\n")
#######################################################
# Build dashboard model setup
SET(MODEL Nightly)
IF(${CTEST_SCRIPT_ARG} MATCHES NightlyCUDA)
SET(MODEL NightlyCUDA)
ENDIF(${CTEST_SCRIPT_ARG} MATCHES NightlyCUDA)
IF(${CTEST_SCRIPT_ARG} MATCHES Experimental)
SET(MODEL Experimental)
ENDIF(${CTEST_SCRIPT_ARG} MATCHES Experimental)
IF(${CTEST_SCRIPT_ARG} MATCHES Continuous)
SET(MODEL Continuous)
ENDIF(${CTEST_SCRIPT_ARG} MATCHES Continuous)
find_program(CTEST_COMMAND_BIN NAMES ctest)
SET (CTEST_COMMAND
"$CTEST_COMMAND_BIN -D ${MODEL}")
#######################################################
# Test custom update with a dashboard script.
message("Running CTest Dashboard Script (custom update)...")
include("${CTEST_SOURCE_DIRECTORY}/CTestConfig.cmake")
ctest_start(${MODEL})
ctest_update(SOURCE ${CTEST_SOURCE_DIRECTORY})
message("Updated.")
ctest_configure(SOURCE "${CTEST_SOURCE_DIRECTORY}" BUILD "${CTEST_BINARY_DIRECTORY}" APPEND)
message("Configured.")
ctest_submit(PARTS Update Configure Notes)
ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}" APPEND)
message("Built.")
ctest_submit(PARTS Build)
message(" -- Install ${MODEL} - ${CTEST_BUILD_NAME} --")
execute_process(COMMAND make install WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} RESULT_VARIABLE ExitCode)
CheckExitCode()
ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" APPEND)
message("Tested.")
ctest_submit(PARTS Test)
message("DONE:CTestScript")