forked from intel/workload-services-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
156 lines (136 loc) · 5.22 KB
/
CMakeLists.txt
File metadata and controls
156 lines (136 loc) · 5.22 KB
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
cmake_minimum_required (VERSION 2.8...3.24)
Project(workloads NONE)
STRING(ASCII 27 esc)
set(red "${esc}[31m")
set(green "${esc}[32m")
set(strikethrough "${esc}[9m")
set(reset "${esc}[0m")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/script/")
include(prerequisite)
add_custom_target(bom)
enable_testing()
set(PLATFORM_CONV_FROM "")
include(platform OPTIONAL)
if(EXISTS "${CMAKE_SOURCE_DIR}/workload/platforms")
set(platforms "${CMAKE_SOURCE_DIR}/workload/platforms")
else()
set(platforms "${CMAKE_SOURCE_DIR}/platforms")
endif()
if(NOT DEFINED PLATFORM)
execute_process(COMMAND bash -c "head -n 1 '${platforms}'" OUTPUT_VARIABLE PLATFORM OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
execute_process(COMMAND bash -c "grep -E '^${PLATFORM}$' '${platforms}' | head -n 1" OUTPUT_VARIABLE platform OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT platform)
message(FATAL_ERROR "Platform ${PLATFORM} not recognized!")
endif()
set(PLATFORM "${platform}")
endif()
include(registry OPTIONAL)
execute_process(COMMAND bash -c "GIT_SSH_COMMAND='ssh -o BatchMode=yes' GIT_ASKPASS=echo git fetch --tags > /dev/null && GIT_ASKPASS=echo git tag" TIMEOUT 5 OUTPUT_VARIABLE tmp RESULT_VARIABLE status OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
if (RELEASE MATCHES "^:?v?[0-9]+[.][0-9]+$")
string(REPLACE ":" "" release1 "${RELEASE}")
if ((status EQUAL 0) AND (tmp MATCHES "${release1}"))
if((NOT DEFINED REGISTRY) OR (NOT REGISTRY))
set(REGISTRY "${DEFAULT_REGISTRY}")
elseif((NOT REGISTRY STREQUAL "${DEFAULT_REGISTRY}") AND DEFAULT_REGISTRY)
message(WARNING "Issue 'cmake -DREGISTRY=${DEFAULT_REGISTRY} ..' to use the official ${RELEASE} images.")
endif()
endif()
else ()
string(REGEX REPLACE ".*\nv?" "" tmp "${tmp}")
if (tmp AND (status EQUAL 0))
message("")
message("*************************************************************")
message("")
message("${green}INFO:${reset} Detected release ${tmp}.")
message(" Switch to release ${tmp} as follows:")
message("")
message("git checkout ${tmp}")
message("cmake -DRELEASE=v${tmp} ..")
message("")
message("*************************************************************")
message("")
else()
message("")
message("****************************************************************************")
message("")
message("${red}WARNING:${reset} Failed to detect any official release.")
message(" Switch to any release as follows:")
message("")
message("git checkout <VERSION>")
message("cmake -DREGISTRY=${DEFAULT_REGISTRY} -DRELEASE=v<VERSION> ..")
message("")
message("****************************************************************************")
endif()
endif()
if (NOT ${REGISTRY} MATCHES "/$")
set(REGISTRY "${REGISTRY}/")
endif()
set(BUILDSH_OPTIONS "")
if (REGISTRY STREQUAL "${DEFAULT_REGISTRY}/")
execute_process(COMMAND bash -c "grep -q -F $(echo ${REGISTRY} | cut -f1 -d/) ~/.docker/config.json" RESULT_VARIABLE disable_build OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
if(disable_build)
set(BUILDSH_OPTIONS "--read-only-registry")
endif()
endif()
if (NOT DEFINED TIMEOUT)
set(TIMEOUT "28800,600")
endif()
if (NOT DEFINED RELEASE)
set(RELEASE ":latest")
elseif (NOT ${RELEASE} MATCHES "^:")
set(RELEASE ":${RELEASE}")
endif()
string(TOLOWER "${RELEASE}" RELEASE)
if ((NOT DEFINED BENCHMARK) AND (EXISTS "${CMAKE_SOURCE_DIR}/workload/dummy"))
set(BENCHMARK "dummy")
message("${red}WARNING:${reset} Default to the dummy workload for quick evaluation.")
message(" Enable specific workload with cmake -DBENCHMARK=<name> .. or")
message(" Enable all workloads with cmake -DBENCHMARK= ..")
message("")
endif()
if (NOT DEFINED BACKEND)
if(EXISTS "${PROJECT_SOURCE_DIR}/script/terraform.cmake")
set(BACKEND "terraform")
endif()
endif()
if(BACKEND)
include(${BACKEND} OPTIONAL)
endif()
set(IMAGEARCH "linux/amd64")
include(multi-arch OPTIONAL)
foreach(subdir image stack workload dist)
if(EXISTS "${PROJECT_SOURCE_DIR}/${subdir}")
add_subdirectory(${subdir})
endif()
endforeach()
message("")
message("-- Setting: PLATFORM=${PLATFORM}${PLATFORM_CONV_FROM}, ARCH=${IMAGEARCH}")
if(NOT DEFINED REGISTRY_AUTH)
message("-- Setting: REGISTRY=${REGISTRY}")
else()
message("-- Setting: REGISTRY=${REGISTRY}, AUTH=${REGISTRY_AUTH}")
endif()
message("-- Setting: RELEASE=${RELEASE}")
if(BACKEND)
message("-- Setting: TIMEOUT=${TIMEOUT}")
endif()
if(ACCEPT_LICENSE)
message("-- Setting: ACCEPT_LICENSE=${ACCEPT_LICENSE}")
endif()
if(BACKEND)
message("-- Setting: BENCHMARK=${BENCHMARK}")
message("-- Setting: BACKEND=${BACKEND}")
endif()
if(COMMAND show_backend_settings)
show_backend_settings()
endif()
message("")
if(BUILDSH_OPTIONS MATCHES "--read-only-registry")
message("${red}INFO:${reset} Docker build is disabled as ${DEFAULT_REGISTRY} is readonly.")
message("")
endif()
if(EXISTS "${PROJECT_SOURCE_DIR}/script/benchmark")
execute_process(COMMAND bash -c "ln -s -r -f '${PROJECT_SOURCE_DIR}'/script/benchmark/*.sh ." WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
endif()
include(legalnotice OPTIONAL)