CMake Nightly Date Stamp
[kiteware-cmake.git] / Source / cmGeneratorTarget_TargetPropertyEntry.cxx
blob9b70f6360a2cb2f90335f9a58f469db5ffdad75d
1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
3 /* clang-format off */
4 #include "cmGeneratorTarget.h"
5 /* clang-format on */
7 #include <map>
8 #include <string>
9 #include <utility>
10 #include <vector>
12 #include <cm/memory>
14 #include "cmFileSet.h"
15 #include "cmGeneratorExpression.h"
16 #include "cmLinkItem.h"
17 #include "cmList.h"
18 #include "cmListFileCache.h"
20 class cmLocalGenerator;
21 class cmake;
22 struct cmGeneratorExpressionDAGChecker;
24 cmLinkImplItem cmGeneratorTarget::TargetPropertyEntry::NoLinkImplItem;
26 class TargetPropertyEntryString : public cmGeneratorTarget::TargetPropertyEntry
28 public:
29 TargetPropertyEntryString(BT<std::string> propertyValue,
30 cmLinkImplItem const& item = NoLinkImplItem)
31 : cmGeneratorTarget::TargetPropertyEntry(item)
32 , PropertyValue(std::move(propertyValue))
36 const std::string& Evaluate(cmLocalGenerator*, const std::string&,
37 cmGeneratorTarget const*,
38 cmGeneratorExpressionDAGChecker*,
39 std::string const&) const override
41 return this->PropertyValue.Value;
44 cmListFileBacktrace GetBacktrace() const override
46 return this->PropertyValue.Backtrace;
48 std::string const& GetInput() const override
50 return this->PropertyValue.Value;
53 private:
54 BT<std::string> PropertyValue;
57 class TargetPropertyEntryGenex : public cmGeneratorTarget::TargetPropertyEntry
59 public:
60 TargetPropertyEntryGenex(std::unique_ptr<cmCompiledGeneratorExpression> cge,
61 cmLinkImplItem const& item = NoLinkImplItem)
62 : cmGeneratorTarget::TargetPropertyEntry(item)
63 , ge(std::move(cge))
67 const std::string& Evaluate(cmLocalGenerator* lg, const std::string& config,
68 cmGeneratorTarget const* headTarget,
69 cmGeneratorExpressionDAGChecker* dagChecker,
70 std::string const& language) const override
72 return this->ge->Evaluate(lg, config, headTarget, dagChecker, nullptr,
73 language);
76 cmListFileBacktrace GetBacktrace() const override
78 return this->ge->GetBacktrace();
81 std::string const& GetInput() const override { return this->ge->GetInput(); }
83 bool GetHadContextSensitiveCondition() const override
85 return this->ge->GetHadContextSensitiveCondition();
88 private:
89 const std::unique_ptr<cmCompiledGeneratorExpression> ge;
92 class TargetPropertyEntryFileSet
93 : public cmGeneratorTarget::TargetPropertyEntry
95 public:
96 TargetPropertyEntryFileSet(
97 std::vector<std::string> dirs, bool contextSensitiveDirs,
98 std::unique_ptr<cmCompiledGeneratorExpression> entryCge,
99 const cmFileSet* fileSet, cmLinkImplItem const& item = NoLinkImplItem)
100 : cmGeneratorTarget::TargetPropertyEntry(item)
101 , BaseDirs(std::move(dirs))
102 , ContextSensitiveDirs(contextSensitiveDirs)
103 , EntryCge(std::move(entryCge))
104 , FileSet(fileSet)
108 const std::string& Evaluate(cmLocalGenerator* lg, const std::string& config,
109 cmGeneratorTarget const* headTarget,
110 cmGeneratorExpressionDAGChecker* dagChecker,
111 std::string const& /*lang*/) const override
113 std::map<std::string, std::vector<std::string>> filesPerDir;
114 this->FileSet->EvaluateFileEntry(this->BaseDirs, filesPerDir,
115 this->EntryCge, lg, config, headTarget,
116 dagChecker);
118 std::vector<std::string> files;
119 for (auto const& it : filesPerDir) {
120 files.insert(files.end(), it.second.begin(), it.second.end());
123 static std::string filesStr;
124 filesStr = cmList::to_string(files);
125 return filesStr;
128 cmListFileBacktrace GetBacktrace() const override
130 return this->EntryCge->GetBacktrace();
133 std::string const& GetInput() const override
135 return this->EntryCge->GetInput();
138 bool GetHadContextSensitiveCondition() const override
140 return this->ContextSensitiveDirs ||
141 this->EntryCge->GetHadContextSensitiveCondition();
144 private:
145 const std::vector<std::string> BaseDirs;
146 const bool ContextSensitiveDirs;
147 const std::unique_ptr<cmCompiledGeneratorExpression> EntryCge;
148 const cmFileSet* FileSet;
151 std::unique_ptr<cmGeneratorTarget::TargetPropertyEntry>
152 cmGeneratorTarget::TargetPropertyEntry::Create(
153 cmake& cmakeInstance, const BT<std::string>& propertyValue,
154 bool evaluateForBuildsystem)
156 if (cmGeneratorExpression::Find(propertyValue.Value) != std::string::npos) {
157 cmGeneratorExpression ge(cmakeInstance, propertyValue.Backtrace);
158 std::unique_ptr<cmCompiledGeneratorExpression> cge =
159 ge.Parse(propertyValue.Value);
160 cge->SetEvaluateForBuildsystem(evaluateForBuildsystem);
161 return std::unique_ptr<cmGeneratorTarget::TargetPropertyEntry>(
162 cm::make_unique<TargetPropertyEntryGenex>(std::move(cge)));
165 return std::unique_ptr<cmGeneratorTarget::TargetPropertyEntry>(
166 cm::make_unique<TargetPropertyEntryString>(propertyValue));
169 std::unique_ptr<cmGeneratorTarget::TargetPropertyEntry>
170 cmGeneratorTarget::TargetPropertyEntry::CreateFileSet(
171 std::vector<std::string> dirs, bool contextSensitiveDirs,
172 std::unique_ptr<cmCompiledGeneratorExpression> entryCge,
173 const cmFileSet* fileSet, cmLinkImplItem const& item)
175 return cm::make_unique<TargetPropertyEntryFileSet>(
176 std::move(dirs), contextSensitiveDirs, std::move(entryCge), fileSet, item);
179 cmGeneratorTarget::TargetPropertyEntry::TargetPropertyEntry(
180 cmLinkImplItem const& item)
181 : LinkImplItem(item)
185 bool cmGeneratorTarget::TargetPropertyEntry::GetHadContextSensitiveCondition()
186 const
188 return false;