forked from InsightSoftwareConsortium/ITK
-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure.cmake
94 lines (79 loc) · 3.4 KB
/
azure.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
# set_from_env
# ------------
#
# Sets a CMake variable from an environment variable. If the
# environment variable is not defined then the CMake variable is not
# modified. If DEFAULT is specified then if the environment variable
# is not defined the default value is used. Alternatively, if REQUIRED
# is specified then a FATAL_ERROR is generated.
#
# set_from_env( <variable> <environment variable> [REQUIRED|DEFAULT value] )
function(set_from_env var env_var)
if(NOT DEFINED ENV{${env_var}})
if (ARGV2 STREQUAL "REQUIRED")
message(FATAL_ERROR "Required environment variable \"${env_var}\" not defined.")
elseif (ARGV2 STREQUAL "DEFAULT")
message("Setting \"${var}\" to default \"${ARGV3}\".")
set(${var} ${ARGV3} PARENT_SCOPE)
endif()
else()
message("Setting \"${var}\" to \"$ENV{${env_var}}\" from environment.")
set(${var} $ENV{${env_var}} PARENT_SCOPE)
endif()
endfunction()
set_from_env(CTEST_SITE "AGENT_MACHINENAME" REQUIRED)
set(CTEST_SITE "Azure.${CTEST_SITE}")
set(CTEST_UPDATE_VERSION_ONLY 1)
set_from_env(PARALLEL_LEVEL "PARALLEL_LEVEL" DEFAULT 3)
set(CTEST_TEST_ARGS ${CTEST_TEST_ARGS} PARALLEL_LEVEL ${PARALLEL_LEVEL})
set_from_env(workspace "AGENT_BUILDDIRECTORY" REQUIRED)
file(TO_CMAKE_PATH "${workspace}" CTEST_DASHBOARD_ROOT)
file(RELATIVE_PATH dashboard_source_name "${workspace}" "$ENV{BUILD_SOURCESDIRECTORY}")
# Make environment variables to CMake variables for CTest
set_from_env(CTEST_CMAKE_GENERATOR "CTEST_CMAKE_GENERATOR" DEFAULT "Ninja")
set_from_env(CTEST_BUILD_CONFIGURATION "CTEST_BUILD_CONFIGURATION" DEFAULT "Release")
set_from_env(dashboard_do_coverage "DASHBOARD_DO_COVERAGE" 0)
set_from_env(CTEST_COVERAGE_COMMAND "CTEST_COVERAGE_COMMAND")
set_from_env(BUILD_SHARED_LIBS "BUILD_SHARED_LIBS" DEFAULT "OFF")
set_from_env(BUILD_EXAMPLES "BUILD_EXAMPLES" DEFAULT "ON")
set_from_env(ITK_WRAP_PYTHON "ITK_WRAP_PYTHON" DEFAULT "OFF")
set_from_env(ITK_BUILD_DEFAULT_MODULES "ITK_BUILD_DEFAULT_MODULES" DEFAULT "ON")
if(NOT CTEST_BUILD_NAME)
if(DEFINED ENV{SYSTEM_PULLREQUEST_SOURCEBRANCH})
set(branch "-$ENV{SYSTEM_PULLREQUEST_SOURCEBRANCH}")
set(dashboard_model "Experimental")
elseif(ENV{BUILD_SOURCEBRANCHNAME} STREQUAL "master")
set(branch "-master")
set(dashboard_model "Continuous")
elseif(ENV{BUILD_SOURCEBRANCHNAME} STREQUAL "nightly-master")
set(branch "-nightly-master")
set(dashboard_model "Nightly")
else()
set(branch "-$ENV{BUILD_SOURCEBRANCHNAME}")
set(dashboard_model "Experimental")
endif()
if(DEFINED ENV{SYSTEM_PULLREQUEST_PULLREQUESTNUMBER})
set(pr "-PR$ENV{SYSTEM_PULLREQUEST_PULLREQUESTNUMBER}")
else()
set(pr "")
endif()
set(wrapping )
if(ITK_WRAP_PYTHON)
set(wrapping "-Python")
endif()
set(CTEST_BUILD_NAME
"$ENV{AGENT_OS}-Build$ENV{BUILD_BUILDID}${pr}${branch}${wrapping}")
endif()
set(_dashboard_cache "
BUILD_EXAMPLES:BOOL=${BUILD_EXAMPLES}
BUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS}
ITK_BUILD_DEFAULT_MODULES:BOOL=${ITK_BUILD_DEFAULT_MODULES}
ITKGroup_Core:BOOL=ON
ITK_WRAP_PYTHON:BOOL=${ITK_WRAP_PYTHON}
" )
set_from_env(dashboard_cache "CTEST_CACHE" DEFAULT ${_dashboard_cache})
set_from_env(DASHBOARD_BRANCH_DIRECTORY "DASHBOARD_BRANCH_DIRECTORY" REQUIRED)
string(TIMESTAMP build_date "%Y-%m-%d")
message("CDash Build Identifier: ${build_date} ${CTEST_BUILD_NAME}")
message("CTEST_SITE = ${CTEST_SITE}")
include("${DASHBOARD_BRANCH_DIRECTORY}/itk_common.cmake")