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