-
Notifications
You must be signed in to change notification settings - Fork 4
/
pmm.cmake
277 lines (210 loc) · 12 KB
/
pmm.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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
#[[
MIT License
Copyright (c) 2021 vector-of-bool
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
////////////////////////////////////////////////////////////////////////////////
PPPPPPPPPPPPPPPP MMMMMM MMMMMM MMMMMM MMMMMM
P:::::::::::::::P M:::::M M:::::M M:::::M M:::::M
P:::::PPPPPP:::::P M::::::M M::::::M M::::::M M::::::M
PP::::P P:::::P M:::::::M M:::::::M M:::::::M M:::::::M
P:::P P:::::P M::::::::M M::::::::M M::::::::M M::::::::M
P:::P P:::::P M:::::::::M M:::::::::M M:::::::::M M:::::::::M
P:::PPPPPP:::::P M:::::M::::M M::::M:::::M M:::::M::::M M::::M:::::M
P::::::::::::PP M::::M M::::M M::::M M::::M M::::M M::::M M::::M M::::M
P:::PPPPPPPPP M::::M M::::M::::M M::::M M::::M M::::M::::M M::::M
P:::P M::::M M:::::::M M::::M M::::M M:::::::M M::::M
P:::P M::::M M:::::M M::::M M::::M M:::::M M::::M
P:::P M::::M MMMMM M::::M M::::M MMMMM M::::M
PP:::::PP M::::M M::::M M::::M M::::M
P:::::::P M::::M M::::M M::::M M::::M
P:::::::P M::::M M::::M M::::M M::::M
PPPPPPPPP MMMMMM MMMMMM MMMMMM MMMMMM
]]
#[[ Version:
888 888 d8b
888 888 Y8P
888 888
Y88b d88P .d88b. 888d888 .d8888b 888 .d88b. 88888b. d8b
Y88b d88P d8P Y8b 888P" 88K 888 d88""88b 888 "88b Y8P
Y88o88P 88888888 888 "Y8888b. 888 888 888 888 888
Y888P Y8b. 888 X88 888 Y88..88P 888 888 d8b
Y8P "Y8888 888 88888P' 888 "Y88P" 888 888 Y8P
The version of PMM that will be downloaded if no PMM_VERSION was specified
before include()-ing this file. You can change this version here to update
the version of PMM that is used by your project: ]]
set(PMM_VERSION_INIT "2.1.0")
# (See the README below for more information)
#
#[[ README:
8888888b. 888 888b d888
888 Y88b 888 8888b d8888
888 888 888 88888b.d88888
888 d88P .d88b. 8888b. .d88888 888Y88888P888 .d88b. d8b
8888888P" d8P Y8b "88b d88" 888 888 Y888P 888 d8P Y8b Y8P
888 T88b 88888888 .d888888 888 888 888 Y8P 888 88888888
888 T88b Y8b. 888 888 Y88b 888 888 " 888 Y8b. d8b
888 T88b "Y8888 "Y888888 "Y88888 888 888 "Y8888 Y8P
####################################################################
This script is the "entrypoint" for PMM.
This file should be COPIED and COMMITTED into the source tree of the project
that wishes to use PMM. Do not use a file(DOWNLOAD), FetchContent(), or other
pre-build script to download this file: It is intended to live in the source
tree of its users and very rarely be manually updated. This file is
in-and-of-itself a FetchContent()-like script that will download and import
the full PMM code.
This script will not automatically upgrade the version of PMM that is imported
unless you specifically request it. You can be assured that the PMM code being
pulled is deterministic over time.
The version of PMM that is bootstrapped by this script is controlled by a
single CMake variable 'PMM_VERSION' that can be set before include()-ing this
file. Additionally, the 'set(PMM_VERSION_INIT)' line above this readme can be
modified to control the PMM version.
HINT: You can run this script with CMake directly via 'cmake -P pmm.cmake' for
additional command-line functionality. ]]
#[[ Options:
.d88888b. 888 d8b
d88P" "Y88b 888 Y8P
888 888 888
888 888 88888b. 888888 888 .d88b. 88888b. .d8888b d8b
888 888 888 "88b 888 888 d88""88b 888 "88b 88K Y8P
888 888 888 888 888 888 888 888 888 888 "Y8888b.
Y88b. .d88P 888 d88P Y88b. 888 Y88..88P 888 888 X88 d8b
"Y88888P" 88888P" "Y888 888 "Y88P" 888 888 88888P' Y8P
888
888
888
##############################################################
The lines below set options that control how PMM is bootstrapped. These
options can all be tweaked in one of two ways:
- Change the default value of the option here in pmm.cmake in the associated
call to pmm_option(). This is useful if you want to make a customized
version of PMM and pmm.cmake to distribute and reuse between projects.
- Set the associated variable before include()-ing this file. This is
preferred for temporary changes, or for one-off projects that need custom
values.
The average user will not need to modify any variables except PMM_VERSION.
Each option is documented below. Additional options and controls for PMM are
documented in the README of the PMM repository.
]]
# (Helpful macro to set a variable if it isn't already set)
macro(pmm_option varname)
if(NOT DEFINED "${varname}" AND NOT DEFINED "CACHE{${varname}}")
set("${varname}" "${ARGN}")
endif()
endmacro()
#[[ PMM_VERSION
d8888b. .88b d88. .88b d88. db db d88888b d8888b. .d8888. d888888b .d88b. d8b db
88 `8D 88'YbdP`88 88'YbdP`88 88 88 88' 88 `8D 88' YP `88' .8P Y8. 888o 88
88oodD' 88 88 88 88 88 88 Y8 8P 88ooooo 88oobY' `8bo. 88 88 88 88V8o 88
88~~~ 88 88 88 88 88 88 `8b d8' 88~~~~~ 88`8b `Y8b. 88 88 88 88 V8o88
88 88 88 88 88 88 88 `8bd8' 88. 88 `88. db 8D .88. `8b d8' 88 V888
88 YP YP YP YP YP YP C88888D YP Y88888P 88 YD `8888Y' Y888888P `Y88P' VP V8P
'PMM_VERSION' will controls what version of PMM will be bootstrapped by this
file.
The initial value is controlled by 'PMM_VERSION_INIT', which is defined near
the top of this file. Permanently updating the PMM version used by the
project should be done by modifying 'PMM_VERSION_INIT' above directly rather
than setting 'PMM_VERSION'
]]
pmm_option(PMM_VERSION ${PMM_VERSION_INIT})
#[[ PMM_URL_BASE
d8888b. .88b d88. .88b d88. db db d8888b. db d8888b. .d8b. .d8888. d88888b
88 `8D 88'YbdP`88 88'YbdP`88 88 88 88 `8D 88 88 `8D d8' `8b 88' YP 88'
88oodD' 88 88 88 88 88 88 88 88 88oobY' 88 88oooY' 88ooo88 `8bo. 88ooooo
88~~~ 88 88 88 88 88 88 88 88 88`8b 88 88~~~b. 88~~~88 `Y8b. 88~~~~~
88 88 88 88 88 88 88 88b d88 88 `88. 88booo. 88 8D 88 88 db 8D 88.
88 YP YP YP YP YP YP C88888D ~Y8888P' 88 YD Y88888P C88888D Y8888P' YP YP `8888Y' Y88888P
'PMM_URL_BASE' sets the root URL from which all versions of PMM can be
downloaded. This value is used to construct 'PMM_URL'.
]]
pmm_option(PMM_URL_BASE "https://vector-of-bool.github.io/pmm")
#[[ PMM_URL
d8888b. .88b d88. .88b d88. db db d8888b. db
88 `8D 88'YbdP`88 88'YbdP`88 88 88 88 `8D 88
88oodD' 88 88 88 88 88 88 88 88 88oobY' 88
88~~~ 88 88 88 88 88 88 88 88 88`8b 88
88 88 88 88 88 88 88 88b d88 88 `88. 88booo.
88 YP YP YP YP YP YP C88888D ~Y8888P' 88 YD Y88888P
'PMM_URL' is a URL that points to the "directory" that contains the PMM
source code for a given version.
The default value is the subdirectory of '${PMM_URL_BASE}' with a name of
'${PMM_VERSION}'.
]]
pmm_option(PMM_URL "${PMM_URL_BASE}/${PMM_VERSION}")
#[[ PMM_DIR
d8888b. .88b d88. .88b d88. d8888b. d888888b d8888b.
88 `8D 88'YbdP`88 88'YbdP`88 88 `8D `88' 88 `8D
88oodD' 88 88 88 88 88 88 88 88 88 88oobY'
88~~~ 88 88 88 88 88 88 88 88 88 88`8b
88 88 88 88 88 88 88 88 .8D .88. 88 `88.
88 YP YP YP YP YP YP C88888D Y8888D' Y888888P 88 YD
'PMM_DIR' is the base directory where PMM will write the bootstrapped copy
of PMM. The default is a subdirectory of the CMake build directory qualified
by the version of PMM that was downloaded.
]]
pmm_option(PMM_DIR "${CMAKE_BINARY_DIR}/_pmm/${PMM_VERSION}")
#[[ PMM_MODULE
d8888b. .88b d88. .88b d88. .88b d88. .d88b. d8888b. db db db d88888b
88 `8D 88'YbdP`88 88'YbdP`88 88'YbdP`88 .8P Y8. 88 `8D 88 88 88 88'
88oodD' 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88ooooo
88~~~ 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88 88~~~~~
88 88 88 88 88 88 88 88 88 88 `8b d8' 88 .8D 88b d88 88booo. 88.
88 YP YP YP YP YP YP C88888D YP YP YP `Y88P' Y8888D' ~Y8888P' Y88888P Y88888P
'PMM_MODULE' is the absolute path to the pmm.cmake script (this file). It
should not be changed or set unless you *really* know what you are doing.
]]
pmm_option(PMM_MODULE "${CMAKE_CURRENT_LIST_FILE}")
################################################################################
################################################################################
################################################################################
################################################################################
#[[
The code below is the implementation of the bootstrapping process for PMM.
You should not change any of the code below.
]]
# The file that we first download
set(_PMM_ENTRY_FILE "${PMM_DIR}/entry.cmake")
# Guard against multiple processes trying to use the PMM dir simultaneously
file(LOCK "${PMM_DIR}/_init-pmm"
GUARD PROCESS
TIMEOUT 10
RESULT_VARIABLE _lock_res
)
if(NOT _lock_res STREQUAL "0")
message(WARNING "PMM entry didn't lock the directory [${PMM_DIR}] successfully (${_lock_res}). We'll continue as best we can.")
set(_pmm_init_did_lock FALSE)
else()
set(_pmm_init_did_lock TRUE)
endif()
if(NOT EXISTS "${_PMM_ENTRY_FILE}" OR PMM_ALWAYS_DOWNLOAD)
file(
DOWNLOAD "${PMM_URL}/entry.cmake"
"${_PMM_ENTRY_FILE}.tmp"
STATUS pair
)
list(GET pair 0 rc)
list(GET pair 1 msg)
if(rc)
message(FATAL_ERROR "Failed to download PMM entry file: ${msg}")
endif()
file(RENAME "${_PMM_ENTRY_FILE}.tmp" "${_PMM_ENTRY_FILE}")
endif()
set(_PMM_BOOTSTRAP_VERSION 4)
include("${_PMM_ENTRY_FILE}")
if(_pmm_init_did_lock)
file(LOCK "${PMM_DIR}/_init-pmm" RELEASE)
endif()