/src/CMake/Source/cmTargetPropertyEntry.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 "cmTargetPropertyEntry.h" |
5 | | |
6 | | #include <string> |
7 | | #include <utility> |
8 | | |
9 | | #include <cm/memory> |
10 | | |
11 | | #include "cmGeneratorExpression.h" |
12 | | #include "cmLinkItem.h" |
13 | | #include "cmListFileCache.h" |
14 | | |
15 | | class cmake; |
16 | | |
17 | | namespace cm { |
18 | | cmLinkItem TargetPropertyEntry::NoLinkItem; |
19 | | |
20 | | class TargetPropertyEntryString : public TargetPropertyEntry |
21 | | { |
22 | | public: |
23 | | TargetPropertyEntryString(BT<std::string> propertyValue, |
24 | | cmLinkItem const& item = NoLinkItem) |
25 | 0 | : TargetPropertyEntry(item) |
26 | 0 | , PropertyValue(std::move(propertyValue)) |
27 | 0 | { |
28 | 0 | } |
29 | | |
30 | | std::string const& Evaluate(cm::GenEx::Context const&, |
31 | | cmGeneratorTarget const*, |
32 | | cmGeneratorExpressionDAGChecker*) const override |
33 | 0 | { |
34 | 0 | return this->PropertyValue.Value; |
35 | 0 | } |
36 | | |
37 | | cmListFileBacktrace GetBacktrace() const override |
38 | 0 | { |
39 | 0 | return this->PropertyValue.Backtrace; |
40 | 0 | } |
41 | | std::string const& GetInput() const override |
42 | 0 | { |
43 | 0 | return this->PropertyValue.Value; |
44 | 0 | } |
45 | | |
46 | | private: |
47 | | BT<std::string> PropertyValue; |
48 | | }; |
49 | | |
50 | | class TargetPropertyEntryGenex : public TargetPropertyEntry |
51 | | { |
52 | | public: |
53 | | TargetPropertyEntryGenex(std::unique_ptr<cmCompiledGeneratorExpression> cge, |
54 | | cmLinkItem const& item = NoLinkItem) |
55 | 0 | : TargetPropertyEntry(item) |
56 | 0 | , ge(std::move(cge)) |
57 | 0 | { |
58 | 0 | } |
59 | | |
60 | | std::string const& Evaluate( |
61 | | cm::GenEx::Context const& context, cmGeneratorTarget const* headTarget, |
62 | | cmGeneratorExpressionDAGChecker* dagChecker) const override |
63 | 0 | { |
64 | 0 | return this->ge->Evaluate(context, dagChecker, headTarget); |
65 | 0 | } |
66 | | |
67 | | cmListFileBacktrace GetBacktrace() const override |
68 | 0 | { |
69 | 0 | return this->ge->GetBacktrace(); |
70 | 0 | } |
71 | | |
72 | 0 | std::string const& GetInput() const override { return this->ge->GetInput(); } |
73 | | |
74 | | bool GetHadContextSensitiveCondition() const override |
75 | 0 | { |
76 | 0 | return this->ge->GetHadContextSensitiveCondition(); |
77 | 0 | } |
78 | | |
79 | | private: |
80 | | std::unique_ptr<cmCompiledGeneratorExpression> const ge; |
81 | | }; |
82 | | |
83 | | std::unique_ptr<TargetPropertyEntry> TargetPropertyEntry::Create( |
84 | | cmake& cmakeInstance, const BT<std::string>& propertyValue, |
85 | | bool evaluateForBuildsystem) |
86 | 0 | { |
87 | 0 | if (cmGeneratorExpression::Find(propertyValue.Value) != std::string::npos) { |
88 | 0 | cmGeneratorExpression ge(cmakeInstance, propertyValue.Backtrace); |
89 | 0 | std::unique_ptr<cmCompiledGeneratorExpression> cge = |
90 | 0 | ge.Parse(propertyValue.Value); |
91 | 0 | cge->SetEvaluateForBuildsystem(evaluateForBuildsystem); |
92 | 0 | return std::unique_ptr<TargetPropertyEntry>( |
93 | 0 | cm::make_unique<TargetPropertyEntryGenex>(std::move(cge))); |
94 | 0 | } |
95 | | |
96 | 0 | return std::unique_ptr<TargetPropertyEntry>( |
97 | 0 | cm::make_unique<TargetPropertyEntryString>(propertyValue)); |
98 | 0 | } |
99 | | |
100 | | TargetPropertyEntry::TargetPropertyEntry(cmLinkItem const& item) |
101 | 0 | : LinkItem(item) |
102 | 0 | { |
103 | 0 | } |
104 | | |
105 | | bool TargetPropertyEntry::GetHadContextSensitiveCondition() const |
106 | 0 | { |
107 | 0 | return false; |
108 | 0 | } |
109 | | } |