/src/CMake/Source/cmStateSnapshot.cxx
Line | Count | Source |
1 | | /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
2 | | file LICENSE.rst or https://cmake.org/licensing for details. */ |
3 | | |
4 | | #include "cmStateSnapshot.h" |
5 | | |
6 | | #include <algorithm> |
7 | | #include <array> |
8 | | #include <cassert> |
9 | | #include <set> |
10 | | #include <string> |
11 | | #include <unordered_map> |
12 | | |
13 | | #include <cm/iterator> |
14 | | #include <cmext/algorithm> |
15 | | |
16 | | #include "cmDefinitions.h" |
17 | | #include "cmLinkedTree.h" |
18 | | #include "cmListFileCache.h" |
19 | | #include "cmPackageState.h" |
20 | | #include "cmPropertyMap.h" |
21 | | #include "cmState.h" |
22 | | #include "cmStateDirectory.h" |
23 | | #include "cmStatePrivate.h" |
24 | | #include "cmSystemTools.h" |
25 | | #include "cmValue.h" |
26 | | #include "cmVersion.h" |
27 | | |
28 | | #if defined(__CYGWIN__) |
29 | | # include "cmStringAlgorithms.h" |
30 | | #endif |
31 | | |
32 | | cmStateSnapshot::cmStateSnapshot(cmState* state) |
33 | 35 | : State(state) |
34 | 35 | { |
35 | 35 | } |
36 | | |
37 | | std::vector<cmStateSnapshot> cmStateSnapshot::GetChildren() |
38 | 0 | { |
39 | 0 | return this->Position->BuildSystemDirectory->Children; |
40 | 0 | } |
41 | | |
42 | | cmStateSnapshot::cmStateSnapshot(cmState* state, |
43 | | cmStateDetail::PositionType position) |
44 | 39 | : State(state) |
45 | 39 | , Position(position) |
46 | 39 | { |
47 | 39 | } |
48 | | |
49 | | cmStateEnums::SnapshotType cmStateSnapshot::GetType() const |
50 | 0 | { |
51 | 0 | return this->Position->SnapshotType; |
52 | 0 | } |
53 | | |
54 | | cmStateEnums::SnapshotUnwindType cmStateSnapshot::GetUnwindType() const |
55 | 0 | { |
56 | 0 | return this->Position->UnwindType; |
57 | 0 | } |
58 | | |
59 | | void cmStateSnapshot::SetUnwindType(cmStateEnums::SnapshotUnwindType type) |
60 | 0 | { |
61 | 0 | this->Position->UnwindType = type; |
62 | 0 | } |
63 | | |
64 | | cmStateEnums::SnapshotUnwindState cmStateSnapshot::GetUnwindState() const |
65 | 0 | { |
66 | 0 | return this->Position->UnwindState; |
67 | 0 | } |
68 | | |
69 | | void cmStateSnapshot::SetUnwindState(cmStateEnums::SnapshotUnwindState state) |
70 | 0 | { |
71 | 0 | this->Position->UnwindState = state; |
72 | 0 | } |
73 | | |
74 | | void cmStateSnapshot::SetListFile(std::string const& listfile) |
75 | 0 | { |
76 | 0 | *this->Position->ExecutionListFile = listfile; |
77 | 0 | } |
78 | | |
79 | | std::string const& cmStateSnapshot::GetExecutionListFile() const |
80 | 0 | { |
81 | 0 | return *this->Position->ExecutionListFile; |
82 | 0 | } |
83 | | |
84 | | bool cmStateSnapshot::IsValid() const |
85 | 72 | { |
86 | 72 | return this->State && this->Position.IsValid() |
87 | 72 | ? this->Position != this->State->SnapshotData.Root() |
88 | 72 | : false; |
89 | 72 | } |
90 | | |
91 | | cmStateSnapshot cmStateSnapshot::GetBuildsystemDirectory() const |
92 | 0 | { |
93 | 0 | return { this->State, this->Position->BuildSystemDirectory->CurrentScope }; |
94 | 0 | } |
95 | | |
96 | | cmStateSnapshot cmStateSnapshot::GetBuildsystemDirectoryParent() const |
97 | 0 | { |
98 | 0 | cmStateSnapshot snapshot; |
99 | 0 | if (!this->State || this->Position == this->State->SnapshotData.Root()) { |
100 | 0 | return snapshot; |
101 | 0 | } |
102 | 0 | cmStateDetail::PositionType parentPos = this->Position->DirectoryParent; |
103 | 0 | if (parentPos != this->State->SnapshotData.Root()) { |
104 | 0 | snapshot = cmStateSnapshot(this->State, |
105 | 0 | parentPos->BuildSystemDirectory->CurrentScope); |
106 | 0 | } |
107 | |
|
108 | 0 | return snapshot; |
109 | 0 | } |
110 | | |
111 | | cmStateSnapshot cmStateSnapshot::GetCallStackParent() const |
112 | 0 | { |
113 | 0 | assert(this->State); |
114 | 0 | assert(this->Position != this->State->SnapshotData.Root()); |
115 | |
|
116 | 0 | cmStateSnapshot snapshot; |
117 | 0 | cmStateDetail::PositionType parentPos = this->Position; |
118 | 0 | while (parentPos->SnapshotType == cmStateEnums::PolicyScopeType || |
119 | 0 | parentPos->SnapshotType == cmStateEnums::VariableScopeType) { |
120 | 0 | ++parentPos; |
121 | 0 | } |
122 | 0 | if (parentPos->SnapshotType == cmStateEnums::BuildsystemDirectoryType || |
123 | 0 | parentPos->SnapshotType == cmStateEnums::BaseType) { |
124 | 0 | return snapshot; |
125 | 0 | } |
126 | | |
127 | 0 | ++parentPos; |
128 | 0 | while (parentPos->SnapshotType == cmStateEnums::PolicyScopeType || |
129 | 0 | parentPos->SnapshotType == cmStateEnums::VariableScopeType) { |
130 | 0 | ++parentPos; |
131 | 0 | } |
132 | |
|
133 | 0 | if (parentPos == this->State->SnapshotData.Root()) { |
134 | 0 | return snapshot; |
135 | 0 | } |
136 | | |
137 | 0 | snapshot = cmStateSnapshot(this->State, parentPos); |
138 | 0 | return snapshot; |
139 | 0 | } |
140 | | |
141 | | cmStateSnapshot cmStateSnapshot::GetCallStackBottom() const |
142 | 0 | { |
143 | 0 | assert(this->State); |
144 | 0 | assert(this->Position != this->State->SnapshotData.Root()); |
145 | |
|
146 | 0 | cmStateDetail::PositionType pos = this->Position; |
147 | 0 | while (pos->SnapshotType != cmStateEnums::BaseType && |
148 | 0 | pos->SnapshotType != cmStateEnums::BuildsystemDirectoryType && |
149 | 0 | pos != this->State->SnapshotData.Root()) { |
150 | 0 | ++pos; |
151 | 0 | } |
152 | 0 | return { this->State, pos }; |
153 | 0 | } |
154 | | |
155 | | void cmStateSnapshot::PushPolicy(cmPolicies::PolicyMap const& entry, bool weak) |
156 | 1 | { |
157 | 1 | cmStateDetail::PositionType pos = this->Position; |
158 | 1 | pos->Policies = this->State->PolicyStack.Push( |
159 | 1 | pos->Policies, cmStateDetail::PolicyStackEntry(entry, weak)); |
160 | 1 | } |
161 | | |
162 | | bool cmStateSnapshot::PopPolicy() |
163 | 0 | { |
164 | 0 | cmStateDetail::PositionType pos = this->Position; |
165 | 0 | if (pos->Policies == pos->PolicyScope) { |
166 | 0 | return false; |
167 | 0 | } |
168 | 0 | pos->Policies = this->State->PolicyStack.Pop(pos->Policies); |
169 | 0 | return true; |
170 | 0 | } |
171 | | |
172 | | bool cmStateSnapshot::CanPopPolicyScope() const |
173 | 1 | { |
174 | 1 | return this->Position->Policies != this->Position->PolicyScope; |
175 | 1 | } |
176 | | |
177 | | void cmStateSnapshot::SetPolicy(cmPolicies::PolicyID id, |
178 | | cmPolicies::PolicyStatus status) |
179 | 0 | { |
180 | | // Update the policy stack from the top to the top-most strong entry. |
181 | 0 | bool previous_was_weak = true; |
182 | 0 | for (cmLinkedTree<cmStateDetail::PolicyStackEntry>::iterator psi = |
183 | 0 | this->Position->Policies; |
184 | 0 | previous_was_weak && psi != this->Position->PolicyRoot; ++psi) { |
185 | 0 | psi->Set(id, status); |
186 | 0 | previous_was_weak = psi->Weak; |
187 | 0 | } |
188 | 0 | } |
189 | | |
190 | | cmPolicies::PolicyStatus cmStateSnapshot::GetPolicy(cmPolicies::PolicyID id, |
191 | | bool parent_scope) const |
192 | 0 | { |
193 | 0 | if (cmPolicies::IsRemoved(id)) { |
194 | 0 | return cmPolicies::NEW; |
195 | 0 | } |
196 | | |
197 | 0 | cmPolicies::PolicyStatus status = cmPolicies::WARN; |
198 | |
|
199 | 0 | cmLinkedTree<cmStateDetail::BuildsystemDirectoryStateType>::iterator dir = |
200 | 0 | this->Position->BuildSystemDirectory; |
201 | |
|
202 | 0 | while (true) { |
203 | 0 | assert(dir.IsValid()); |
204 | 0 | cmLinkedTree<cmStateDetail::PolicyStackEntry>::iterator leaf = |
205 | 0 | dir->CurrentScope->Policies; |
206 | 0 | cmLinkedTree<cmStateDetail::PolicyStackEntry>::iterator root = |
207 | 0 | dir->CurrentScope->PolicyRoot; |
208 | 0 | for (; leaf != root; ++leaf) { |
209 | 0 | if (parent_scope) { |
210 | 0 | parent_scope = false; |
211 | 0 | continue; |
212 | 0 | } |
213 | 0 | if (leaf->IsDefined(id)) { |
214 | 0 | status = leaf->Get(id); |
215 | 0 | return status; |
216 | 0 | } |
217 | 0 | } |
218 | 0 | cmStateDetail::PositionType e = dir->CurrentScope; |
219 | 0 | cmStateDetail::PositionType p = e->DirectoryParent; |
220 | 0 | if (p == this->State->SnapshotData.Root()) { |
221 | 0 | break; |
222 | 0 | } |
223 | 0 | dir = p->BuildSystemDirectory; |
224 | 0 | } |
225 | 0 | return status; |
226 | 0 | } |
227 | | |
228 | | void cmStateSnapshot::PushDiagnostic(cmDiagnostics::DiagnosticMap entry, |
229 | | bool weak) |
230 | 1 | { |
231 | 1 | cmStateDetail::PositionType pos = this->Position; |
232 | 1 | pos->Diagnostics = this->State->DiagnosticStack.Push( |
233 | 1 | pos->Diagnostics, cmStateDetail::DiagnosticStackEntry(entry, weak)); |
234 | 1 | } |
235 | | |
236 | | bool cmStateSnapshot::PopDiagnostic() |
237 | 0 | { |
238 | 0 | cmStateDetail::PositionType pos = this->Position; |
239 | 0 | if (pos->Diagnostics == pos->DiagnosticScope) { |
240 | 0 | return false; |
241 | 0 | } |
242 | 0 | pos->Diagnostics = this->State->DiagnosticStack.Pop(pos->Diagnostics); |
243 | 0 | return true; |
244 | 0 | } |
245 | | |
246 | | bool cmStateSnapshot::CanPopDiagnosticScope() const |
247 | 1 | { |
248 | 1 | return this->Position->Diagnostics != this->Position->DiagnosticScope; |
249 | 1 | } |
250 | | |
251 | | void cmStateSnapshot::SetDiagnostic(cmDiagnosticCategory category, |
252 | | cmDiagnosticAction action, bool recursive) |
253 | 0 | { |
254 | 0 | assert(action != cmDiagnostics::Undefined); |
255 | |
|
256 | 0 | auto function = [](cmDiagnosticAction, cmDiagnosticAction) -> bool { |
257 | 0 | return true; |
258 | 0 | }; |
259 | |
|
260 | 0 | this->AlterDiagnostic(category, action, function, recursive); |
261 | 0 | } |
262 | | |
263 | | void cmStateSnapshot::PromoteDiagnostic(cmDiagnosticCategory category, |
264 | | cmDiagnosticAction action, |
265 | | bool recursive) |
266 | 0 | { |
267 | 0 | assert(action != cmDiagnostics::Undefined); |
268 | |
|
269 | 0 | auto function = [](cmDiagnosticAction current, |
270 | 0 | cmDiagnosticAction desired) -> bool { |
271 | 0 | return (current < desired); |
272 | 0 | }; |
273 | |
|
274 | 0 | this->AlterDiagnostic(category, action, function, recursive); |
275 | 0 | } |
276 | | |
277 | | void cmStateSnapshot::DemoteDiagnostic(cmDiagnosticCategory category, |
278 | | cmDiagnosticAction action, |
279 | | bool recursive) |
280 | 0 | { |
281 | 0 | assert(action != cmDiagnostics::Undefined); |
282 | |
|
283 | 0 | auto function = [](cmDiagnosticAction current, |
284 | 0 | cmDiagnosticAction desired) -> bool { |
285 | 0 | return (current > desired); |
286 | 0 | }; |
287 | |
|
288 | 0 | this->AlterDiagnostic(category, action, function, recursive); |
289 | 0 | } |
290 | | |
291 | | void cmStateSnapshot::AlterDiagnostic(cmDiagnosticCategory category, |
292 | | cmDiagnosticAction action, |
293 | | AlterDiagnosticFunction function, |
294 | | bool recursive) |
295 | 0 | { |
296 | 0 | if (recursive) { |
297 | 0 | unsigned i = category; |
298 | 0 | for (;;) { |
299 | 0 | this->AlterDiagnostic(static_cast<cmDiagnosticCategory>(i), action, |
300 | 0 | function, false); |
301 | 0 | if (++i >= cmDiagnostics::CategoryCount) { |
302 | 0 | break; |
303 | 0 | } |
304 | 0 | if (cmDiagnostics::CategoryInfo[i].Parent < category) { |
305 | 0 | break; |
306 | 0 | } |
307 | 0 | } |
308 | 0 | } else { |
309 | 0 | cmDiagnosticAction const oldAction = this->GetDiagnostic(category); |
310 | 0 | if (function(oldAction, action)) { |
311 | | // Update the policy stack from the top to the top-most strong entry. |
312 | 0 | bool previous_was_weak = true; |
313 | 0 | for (cmLinkedTree<cmStateDetail::DiagnosticStackEntry>::iterator dsi = |
314 | 0 | this->Position->Diagnostics; |
315 | 0 | previous_was_weak && dsi != this->Position->DiagnosticRoot; ++dsi) { |
316 | 0 | (*dsi)[category] = action; |
317 | 0 | previous_was_weak = dsi->Weak; |
318 | 0 | } |
319 | 0 | } |
320 | 0 | } |
321 | 0 | } |
322 | | |
323 | | cmDiagnosticAction cmStateSnapshot::GetDiagnostic( |
324 | | cmDiagnosticCategory category, cmDiagnosticAction defaultAction) const |
325 | 0 | { |
326 | 0 | cmLinkedTree<cmStateDetail::BuildsystemDirectoryStateType>::iterator dir = |
327 | 0 | this->Position->BuildSystemDirectory; |
328 | |
|
329 | 0 | while (true) { |
330 | 0 | assert(dir.IsValid()); |
331 | 0 | cmLinkedTree<cmStateDetail::DiagnosticStackEntry>::iterator leaf = |
332 | 0 | dir->CurrentScope->Diagnostics; |
333 | 0 | cmLinkedTree<cmStateDetail::DiagnosticStackEntry>::iterator root = |
334 | 0 | dir->CurrentScope->DiagnosticRoot; |
335 | 0 | for (; leaf != root; ++leaf) { |
336 | 0 | cmDiagnosticAction const action = (*leaf)[category]; |
337 | 0 | if (action != cmDiagnostics::Undefined) { |
338 | 0 | return action; |
339 | 0 | } |
340 | 0 | } |
341 | 0 | cmStateDetail::PositionType e = dir->CurrentScope; |
342 | 0 | cmStateDetail::PositionType p = e->DirectoryParent; |
343 | 0 | if (p == this->State->SnapshotData.Root()) { |
344 | 0 | break; |
345 | 0 | } |
346 | 0 | dir = p->BuildSystemDirectory; |
347 | 0 | } |
348 | 0 | return defaultAction; |
349 | 0 | } |
350 | | |
351 | | cmValue cmStateSnapshot::GetDefinition(std::string const& name) const |
352 | 6 | { |
353 | 6 | assert(this->Position->Vars.IsValid()); |
354 | 6 | return cmDefinitions::Get(name, this->Position->Vars, this->Position->Root); |
355 | 6 | } |
356 | | |
357 | | bool cmStateSnapshot::IsInitialized(std::string const& name) const |
358 | 0 | { |
359 | 0 | return cmDefinitions::HasKey(name, this->Position->Vars, |
360 | 0 | this->Position->Root); |
361 | 0 | } |
362 | | |
363 | | void cmStateSnapshot::SetDefinition(std::string const& name, |
364 | | cm::string_view value) |
365 | 95 | { |
366 | 95 | this->Position->Vars->Set(name, value); |
367 | 95 | } |
368 | | |
369 | | void cmStateSnapshot::RemoveDefinition(std::string const& name) |
370 | 1 | { |
371 | 1 | this->Position->Vars->Unset(name); |
372 | 1 | } |
373 | | |
374 | | std::vector<std::string> cmStateSnapshot::ClosureKeys() const |
375 | 0 | { |
376 | 0 | return cmDefinitions::ClosureKeys(this->Position->Vars, |
377 | 0 | this->Position->Root); |
378 | 0 | } |
379 | | |
380 | | bool cmStateSnapshot::RaiseScope(std::string const& var, char const* varDef) |
381 | 0 | { |
382 | 0 | if (this->Position->ScopeParent == this->Position->DirectoryParent) { |
383 | 0 | cmStateSnapshot parentDir = this->GetBuildsystemDirectoryParent(); |
384 | 0 | if (!parentDir.IsValid()) { |
385 | 0 | return false; |
386 | 0 | } |
387 | | // Update the definition in the parent directory top scope. This |
388 | | // directory's scope was initialized by the closure of the parent |
389 | | // scope, so we do not need to localize the definition first. |
390 | 0 | if (varDef) { |
391 | 0 | parentDir.SetDefinition(var, varDef); |
392 | 0 | } else { |
393 | 0 | parentDir.RemoveDefinition(var); |
394 | 0 | } |
395 | 0 | return true; |
396 | 0 | } |
397 | | // First localize the definition in the current scope. |
398 | 0 | cmDefinitions::Raise(var, this->Position->Vars, this->Position->Root); |
399 | | |
400 | | // Now update the definition in the parent scope. |
401 | 0 | if (varDef) { |
402 | 0 | this->Position->Parent->Set(var, varDef); |
403 | 0 | } else { |
404 | 0 | this->Position->Parent->Unset(var); |
405 | 0 | } |
406 | 0 | return true; |
407 | 0 | } |
408 | | |
409 | | template <typename T, typename U> |
410 | | void InitializeContentFromParent(T& parentContent, T& thisContent, |
411 | | U& contentEndPosition) |
412 | 0 | { |
413 | 0 | auto parentEnd = parentContent.end(); |
414 | |
|
415 | 0 | auto parentRbegin = cm::make_reverse_iterator(parentEnd); |
416 | 0 | auto parentRend = parentContent.rend(); |
417 | 0 | parentRbegin = |
418 | 0 | std::find(parentRbegin, parentRend, cmStateDetail::PropertySentinel); |
419 | 0 | auto parentIt = parentRbegin.base(); |
420 | |
|
421 | 0 | thisContent = std::vector<BT<std::string>>(parentIt, parentEnd); |
422 | |
|
423 | 0 | contentEndPosition = thisContent.size(); |
424 | 0 | } |
425 | | |
426 | | void cmStateSnapshot::SetDefaultDefinitions() |
427 | 1 | { |
428 | | /* Up to CMake 2.4 here only WIN32, UNIX and APPLE were set. |
429 | | With CMake must separate between target and host platform. In most cases |
430 | | the tests for WIN32, UNIX and APPLE will be for the target system, so an |
431 | | additional set of variables for the host system is required -> |
432 | | CMAKE_HOST_WIN32, CMAKE_HOST_UNIX, CMAKE_HOST_APPLE. |
433 | | WIN32, UNIX and APPLE are now set in the platform files in |
434 | | Modules/Platforms/. |
435 | | To keep cmake scripts (-P) and custom language and compiler modules |
436 | | working, these variables are still also set here in this place, but they |
437 | | will be reset in CMakeSystemSpecificInformation.cmake before the platform |
438 | | files are executed. */ |
439 | 1 | cm::string_view hostSystemName = cmSystemTools::GetSystemName(); |
440 | 1 | this->SetDefinition("CMAKE_HOST_SYSTEM_NAME", hostSystemName); |
441 | 1 | if (hostSystemName == "Windows") { |
442 | 0 | this->SetDefinition("WIN32", "1"); |
443 | 0 | this->SetDefinition("CMAKE_HOST_WIN32", "1"); |
444 | 0 | this->SetDefinition("CMAKE_HOST_EXECUTABLE_SUFFIX", ".exe"); |
445 | 1 | } else { |
446 | 1 | this->SetDefinition("UNIX", "1"); |
447 | 1 | this->SetDefinition("CMAKE_HOST_UNIX", "1"); |
448 | 1 | this->SetDefinition("CMAKE_HOST_EXECUTABLE_SUFFIX", ""); |
449 | 1 | } |
450 | | #if defined(__APPLE__) |
451 | | this->SetDefinition("APPLE", "1"); |
452 | | this->SetDefinition("CMAKE_HOST_APPLE", "1"); |
453 | | #endif |
454 | | #if defined(__sun__) |
455 | | this->SetDefinition("CMAKE_HOST_SOLARIS", "1"); |
456 | | #endif |
457 | | |
458 | | #if defined(__OpenBSD__) |
459 | | this->SetDefinition("BSD", "OpenBSD"); |
460 | | this->SetDefinition("CMAKE_HOST_BSD", "OpenBSD"); |
461 | | #elif defined(__FreeBSD__) |
462 | | this->SetDefinition("BSD", "FreeBSD"); |
463 | | this->SetDefinition("CMAKE_HOST_BSD", "FreeBSD"); |
464 | | #elif defined(__NetBSD__) |
465 | | this->SetDefinition("BSD", "NetBSD"); |
466 | | this->SetDefinition("CMAKE_HOST_BSD", "NetBSD"); |
467 | | #elif defined(__DragonFly__) |
468 | | this->SetDefinition("BSD", "DragonFlyBSD"); |
469 | | this->SetDefinition("CMAKE_HOST_BSD", "DragonFlyBSD"); |
470 | | #endif |
471 | | |
472 | 1 | #if defined(__linux__) |
473 | 1 | this->SetDefinition("LINUX", "1"); |
474 | 1 | this->SetDefinition("CMAKE_HOST_LINUX", "1"); |
475 | 1 | #endif |
476 | | |
477 | | #if defined(_AIX) |
478 | | this->SetDefinition("AIX", "1"); |
479 | | this->SetDefinition("CMAKE_HOST_AIX", "1"); |
480 | | #endif |
481 | | |
482 | 1 | this->SetDefinition("CMAKE_MAJOR_VERSION", |
483 | 1 | std::to_string(cmVersion::GetMajorVersion())); |
484 | 1 | this->SetDefinition("CMAKE_MINOR_VERSION", |
485 | 1 | std::to_string(cmVersion::GetMinorVersion())); |
486 | 1 | this->SetDefinition("CMAKE_PATCH_VERSION", |
487 | 1 | std::to_string(cmVersion::GetPatchVersion())); |
488 | 1 | this->SetDefinition("CMAKE_TWEAK_VERSION", |
489 | 1 | std::to_string(cmVersion::GetTweakVersion())); |
490 | 1 | this->SetDefinition("CMAKE_VERSION", cmVersion::GetCMakeVersion()); |
491 | | |
492 | 1 | this->SetDefinition("CMAKE_FILES_DIRECTORY", "/CMakeFiles"); |
493 | | |
494 | | // Setup the default include file regular expression (match everything). |
495 | 1 | this->Position->BuildSystemDirectory->Properties.SetProperty( |
496 | 1 | "INCLUDE_REGULAR_EXPRESSION", "^.*$"); |
497 | 1 | } |
498 | | |
499 | | void cmStateSnapshot::SetDirectoryDefinitions() |
500 | 0 | { |
501 | 0 | this->SetDefinition("CMAKE_SOURCE_DIR", this->State->GetSourceDirectory()); |
502 | 0 | this->SetDefinition("CMAKE_CURRENT_SOURCE_DIR", |
503 | 0 | this->State->GetSourceDirectory()); |
504 | 0 | this->SetDefinition("CMAKE_BINARY_DIR", this->State->GetBinaryDirectory()); |
505 | 0 | this->SetDefinition("CMAKE_CURRENT_BINARY_DIR", |
506 | 0 | this->State->GetBinaryDirectory()); |
507 | 0 | } |
508 | | |
509 | | void cmStateSnapshot::InitializeFromParent() |
510 | 0 | { |
511 | 0 | cmStateDetail::PositionType parent = this->Position->DirectoryParent; |
512 | 0 | assert(this->Position->Vars.IsValid()); |
513 | 0 | assert(parent->Vars.IsValid()); |
514 | |
|
515 | 0 | *this->Position->Vars = |
516 | 0 | cmDefinitions::MakeClosure(parent->Vars, parent->Root); |
517 | |
|
518 | 0 | InitializeContentFromParent( |
519 | 0 | parent->BuildSystemDirectory->IncludeDirectories, |
520 | 0 | this->Position->BuildSystemDirectory->IncludeDirectories, |
521 | 0 | this->Position->IncludeDirectoryPosition); |
522 | |
|
523 | 0 | InitializeContentFromParent( |
524 | 0 | parent->BuildSystemDirectory->CompileDefinitions, |
525 | 0 | this->Position->BuildSystemDirectory->CompileDefinitions, |
526 | 0 | this->Position->CompileDefinitionsPosition); |
527 | |
|
528 | 0 | InitializeContentFromParent( |
529 | 0 | parent->BuildSystemDirectory->CompileOptions, |
530 | 0 | this->Position->BuildSystemDirectory->CompileOptions, |
531 | 0 | this->Position->CompileOptionsPosition); |
532 | |
|
533 | 0 | InitializeContentFromParent( |
534 | 0 | parent->BuildSystemDirectory->LinkOptions, |
535 | 0 | this->Position->BuildSystemDirectory->LinkOptions, |
536 | 0 | this->Position->LinkOptionsPosition); |
537 | |
|
538 | 0 | InitializeContentFromParent( |
539 | 0 | parent->BuildSystemDirectory->LinkDirectories, |
540 | 0 | this->Position->BuildSystemDirectory->LinkDirectories, |
541 | 0 | this->Position->LinkDirectoriesPosition); |
542 | |
|
543 | 0 | cmValue include_regex = |
544 | 0 | parent->BuildSystemDirectory->Properties.GetPropertyValue( |
545 | 0 | "INCLUDE_REGULAR_EXPRESSION"); |
546 | 0 | this->Position->BuildSystemDirectory->Properties.SetProperty( |
547 | 0 | "INCLUDE_REGULAR_EXPRESSION", include_regex); |
548 | 0 | } |
549 | | |
550 | | cmState* cmStateSnapshot::GetState() const |
551 | 1 | { |
552 | 1 | return this->State; |
553 | 1 | } |
554 | | |
555 | | cmStateDirectory cmStateSnapshot::GetDirectory() const |
556 | 3 | { |
557 | 3 | return { this->Position->BuildSystemDirectory, *this }; |
558 | 3 | } |
559 | | |
560 | | void cmStateSnapshot::SetProjectName(std::string const& name) |
561 | 0 | { |
562 | 0 | this->Position->BuildSystemDirectory->ProjectName = name; |
563 | 0 | this->Position->BuildSystemDirectory->Projects.insert(name); |
564 | 0 | } |
565 | | |
566 | | std::string cmStateSnapshot::GetProjectName() const |
567 | 0 | { |
568 | 0 | return this->Position->BuildSystemDirectory->ProjectName; |
569 | 0 | } |
570 | | |
571 | | bool cmStateSnapshot::CheckProjectName(std::string const& name) const |
572 | 0 | { |
573 | 0 | return cm::contains(this->Position->BuildSystemDirectory->Projects, name); |
574 | 0 | } |
575 | | |
576 | | cmPackageState& cmStateSnapshot::GetPackageState( |
577 | | std::string const& packagePath) |
578 | 0 | { |
579 | 0 | return this->Position->BuildSystemDirectory->Packages[packagePath]; |
580 | 0 | } |
581 | | |
582 | | void cmStateSnapshot::InitializeFromParent_ForSubdirsCommand() |
583 | 0 | { |
584 | 0 | std::string currentSrcDir = *this->GetDefinition("CMAKE_CURRENT_SOURCE_DIR"); |
585 | 0 | std::string currentBinDir = *this->GetDefinition("CMAKE_CURRENT_BINARY_DIR"); |
586 | 0 | this->InitializeFromParent(); |
587 | 0 | this->SetDefinition("CMAKE_SOURCE_DIR", this->State->GetSourceDirectory()); |
588 | 0 | this->SetDefinition("CMAKE_BINARY_DIR", this->State->GetBinaryDirectory()); |
589 | |
|
590 | 0 | this->SetDefinition("CMAKE_CURRENT_SOURCE_DIR", currentSrcDir); |
591 | 0 | this->SetDefinition("CMAKE_CURRENT_BINARY_DIR", currentBinDir); |
592 | 0 | } |
593 | | |
594 | | bool cmStateSnapshot::StrictWeakOrder::operator()( |
595 | | cmStateSnapshot const& lhs, cmStateSnapshot const& rhs) const |
596 | 0 | { |
597 | 0 | return lhs.Position.StrictWeakOrdered(rhs.Position); |
598 | 0 | } |
599 | | |
600 | | bool operator==(cmStateSnapshot const& lhs, cmStateSnapshot const& rhs) |
601 | 0 | { |
602 | 0 | return lhs.Position == rhs.Position; |
603 | 0 | } |
604 | | |
605 | | bool operator!=(cmStateSnapshot const& lhs, cmStateSnapshot const& rhs) |
606 | 0 | { |
607 | 0 | return lhs.Position != rhs.Position; |
608 | 0 | } |