/src/CMake/Source/cmEvaluatedTargetProperty.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 | | #include "cmEvaluatedTargetProperty.h" |
4 | | |
5 | | #include <unordered_map> |
6 | | #include <utility> |
7 | | |
8 | | #include "cmGenExContext.h" |
9 | | #include "cmGenExEvaluation.h" |
10 | | #include "cmGeneratorTarget.h" |
11 | | #include "cmLinkItem.h" |
12 | | #include "cmList.h" |
13 | | #include "cmTargetPropertyEntry.h" |
14 | | |
15 | | struct cmGeneratorExpressionDAGChecker; |
16 | | |
17 | | EvaluatedTargetPropertyEntry::EvaluatedTargetPropertyEntry( |
18 | | cmLinkItem const& item, cmListFileBacktrace bt) |
19 | 0 | : LinkItem(item) |
20 | 0 | , Backtrace(std::move(bt)) |
21 | 0 | { |
22 | 0 | } |
23 | | |
24 | | EvaluatedTargetPropertyEntry EvaluateTargetPropertyEntry( |
25 | | cmGeneratorTarget const* thisTarget, cm::GenEx::Context const& context, |
26 | | cmGeneratorExpressionDAGChecker* dagChecker, cm::TargetPropertyEntry& entry) |
27 | 0 | { |
28 | 0 | EvaluatedTargetPropertyEntry ee(entry.LinkItem, entry.GetBacktrace()); |
29 | 0 | cmExpandList(entry.Evaluate(context, thisTarget, dagChecker), ee.Values); |
30 | 0 | if (entry.GetHadContextSensitiveCondition()) { |
31 | 0 | ee.ContextDependent = true; |
32 | 0 | } |
33 | 0 | return ee; |
34 | 0 | } |
35 | | |
36 | | EvaluatedTargetPropertyEntries EvaluateTargetPropertyEntries( |
37 | | cmGeneratorTarget const* thisTarget, cm::GenEx::Context const& context, |
38 | | cmGeneratorExpressionDAGChecker* dagChecker, |
39 | | std::vector<std::unique_ptr<cm::TargetPropertyEntry>> const& in) |
40 | 0 | { |
41 | 0 | EvaluatedTargetPropertyEntries out; |
42 | 0 | out.Entries.reserve(in.size()); |
43 | 0 | for (auto const& entry : in) { |
44 | 0 | out.Entries.emplace_back( |
45 | 0 | EvaluateTargetPropertyEntry(thisTarget, context, dagChecker, *entry)); |
46 | 0 | } |
47 | 0 | return out; |
48 | 0 | } |
49 | | |
50 | | namespace { |
51 | | void addInterfaceEntry(cmGeneratorTarget const* headTarget, |
52 | | std::string const& prop, |
53 | | cm::GenEx::Context const& context, |
54 | | cmGeneratorExpressionDAGChecker* dagChecker, |
55 | | EvaluatedTargetPropertyEntries& entries, |
56 | | cmGeneratorTarget::UseTo usage, |
57 | | std::vector<cmLinkItem> const& libraries) |
58 | 0 | { |
59 | 0 | for (cmLinkItem const& lib : libraries) { |
60 | 0 | if (lib.Target) { |
61 | 0 | EvaluatedTargetPropertyEntry ee(lib, lib.Backtrace); |
62 | | // Pretend $<TARGET_PROPERTY:lib.Target,prop> appeared in our |
63 | | // caller's property and hand-evaluate it as if it were compiled. |
64 | | // Create a context as cmCompiledGeneratorExpression::Evaluate does. |
65 | 0 | cm::GenEx::Evaluation eval(context, false, headTarget, headTarget, true, |
66 | 0 | lib.Backtrace); |
67 | 0 | cmExpandList( |
68 | 0 | lib.Target->EvaluateInterfaceProperty(prop, &eval, dagChecker, usage), |
69 | 0 | ee.Values); |
70 | 0 | ee.ContextDependent = eval.HadContextSensitiveCondition; |
71 | 0 | entries.Entries.emplace_back(std::move(ee)); |
72 | 0 | } |
73 | 0 | } |
74 | 0 | } |
75 | | } |
76 | | |
77 | | void AddInterfaceEntries(cmGeneratorTarget const* headTarget, |
78 | | std::string const& prop, |
79 | | cm::GenEx::Context const& context, |
80 | | cmGeneratorExpressionDAGChecker* dagChecker, |
81 | | EvaluatedTargetPropertyEntries& entries, |
82 | | IncludeRuntimeInterface searchRuntime, |
83 | | cmGeneratorTarget::UseTo usage) |
84 | 0 | { |
85 | 0 | if (searchRuntime == IncludeRuntimeInterface::Yes) { |
86 | 0 | if (cmLinkImplementation const* impl = |
87 | 0 | headTarget->GetLinkImplementation(context.Config, usage)) { |
88 | 0 | entries.HadContextSensitiveCondition = |
89 | 0 | impl->HadContextSensitiveCondition; |
90 | |
|
91 | 0 | auto runtimeLibIt = |
92 | 0 | impl->LanguageRuntimeLibraries.find(context.Language); |
93 | 0 | if (runtimeLibIt != impl->LanguageRuntimeLibraries.end()) { |
94 | 0 | addInterfaceEntry(headTarget, prop, context, dagChecker, entries, |
95 | 0 | usage, runtimeLibIt->second); |
96 | 0 | } |
97 | 0 | addInterfaceEntry(headTarget, prop, context, dagChecker, entries, usage, |
98 | 0 | impl->Libraries); |
99 | 0 | } |
100 | 0 | } else { |
101 | 0 | if (cmLinkImplementationLibraries const* impl = |
102 | 0 | headTarget->GetLinkImplementationLibraries(context.Config, usage)) { |
103 | 0 | entries.HadContextSensitiveCondition = |
104 | 0 | impl->HadContextSensitiveCondition; |
105 | 0 | addInterfaceEntry(headTarget, prop, context, dagChecker, entries, usage, |
106 | 0 | impl->Libraries); |
107 | 0 | } |
108 | 0 | } |
109 | 0 | } |