/src/CMake/Source/cmGeneratorExpressionDAGChecker.h
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 | | #pragma once |
4 | | |
5 | | #include "cmConfigure.h" // IWYU pragma: keep |
6 | | |
7 | | #include <map> |
8 | | #include <set> |
9 | | #include <string> |
10 | | |
11 | | #include "cmListFileCache.h" |
12 | | |
13 | | namespace cm { |
14 | | namespace GenEx { |
15 | | struct Context; |
16 | | struct Evaluation; |
17 | | } |
18 | | } |
19 | | |
20 | | struct GeneratorExpressionContent; |
21 | | class cmGeneratorTarget; |
22 | | |
23 | | struct cmGeneratorExpressionDAGChecker |
24 | | { |
25 | | enum class ComputingLinkLibraries |
26 | | { |
27 | | No, |
28 | | Yes, |
29 | | }; |
30 | | cmGeneratorExpressionDAGChecker( |
31 | | cmGeneratorTarget const* target, std::string property, |
32 | | GeneratorExpressionContent const* content, |
33 | | cmGeneratorExpressionDAGChecker* parent, cm::GenEx::Context const& context, |
34 | | cmListFileBacktrace backtrace = cmListFileBacktrace(), |
35 | | ComputingLinkLibraries computingLinkLibraries = |
36 | | ComputingLinkLibraries::No); |
37 | | |
38 | | enum Result |
39 | | { |
40 | | DAG, |
41 | | SELF_REFERENCE, |
42 | | CYCLIC_REFERENCE, |
43 | | ALREADY_SEEN |
44 | | }; |
45 | | |
46 | | Result Check() const; |
47 | | |
48 | | void ReportError(cm::GenEx::Evaluation* eval, std::string const& expr); |
49 | | |
50 | | bool EvaluatingTransitiveProperty() const; |
51 | | bool EvaluatingGenexExpression() const; |
52 | | bool EvaluatingPICExpression() const; |
53 | | bool EvaluatingCompileExpression() const; |
54 | | bool EvaluatingLinkExpression() const; |
55 | | bool EvaluatingLinkOptionsExpression() const; |
56 | | bool EvaluatingLinkerLauncher() const; |
57 | | |
58 | | /** Returns true only when computing the actual link dependency |
59 | | graph for cmGeneratorTarget::GetLinkImplementationLibraries |
60 | | or cmGeneratorTarget::GetLinkInterfaceLibraries. */ |
61 | | bool IsComputingLinkLibraries() const; |
62 | | |
63 | | enum class ForGenex |
64 | | { |
65 | | ANY, |
66 | | LINK_LIBRARY, |
67 | | LINK_GROUP |
68 | | }; |
69 | | bool EvaluatingLinkLibraries(cmGeneratorTarget const* tgt = nullptr, |
70 | | ForGenex genex = ForGenex::ANY) const; |
71 | | |
72 | | bool EvaluatingSources() const; |
73 | | |
74 | | bool GetTransitivePropertiesOnly() const; |
75 | 0 | void SetTransitivePropertiesOnly() { this->TransitivePropertiesOnly = true; } |
76 | | |
77 | | bool GetTransitivePropertiesOnlyCMP0131() const; |
78 | 0 | void SetTransitivePropertiesOnlyCMP0131() { this->CMP0131 = true; } |
79 | | |
80 | | cmGeneratorTarget const* TopTarget() const; |
81 | | |
82 | | private: |
83 | | Result CheckGraph() const; |
84 | | |
85 | | cmGeneratorExpressionDAGChecker const* const Parent; |
86 | | cmGeneratorExpressionDAGChecker const* const Top; |
87 | | cmGeneratorTarget const* Target; |
88 | | std::string const Property; |
89 | | mutable std::map<cmGeneratorTarget const*, std::set<std::string>> Seen; |
90 | | GeneratorExpressionContent const* const Content; |
91 | | cmListFileBacktrace const Backtrace; |
92 | | Result CheckResult; |
93 | | bool TransitivePropertiesOnly = false; |
94 | | bool CMP0131 = false; |
95 | | bool TopIsTransitiveProperty = false; |
96 | | ComputingLinkLibraries const ComputingLinkLibraries_ = |
97 | | ComputingLinkLibraries::No; |
98 | | }; |