/src/CMake/Source/cmInstallRuntimeDependencySet.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 <map> |
6 | | #include <set> |
7 | | #include <string> |
8 | | #include <vector> |
9 | | |
10 | | #include <cm/memory> |
11 | | #include <cm/string_view> |
12 | | #include <cmext/string_view> |
13 | | |
14 | | class cmGeneratorTarget; |
15 | | class cmInstallImportedRuntimeArtifactsGenerator; |
16 | | class cmInstallTargetGenerator; |
17 | | |
18 | | class cmInstallRuntimeDependencySet |
19 | | { |
20 | | public: |
21 | | cmInstallRuntimeDependencySet(std::string name = ""); |
22 | | |
23 | | cmInstallRuntimeDependencySet(cmInstallRuntimeDependencySet const&) = delete; |
24 | | cmInstallRuntimeDependencySet& operator=( |
25 | | cmInstallRuntimeDependencySet const&) = delete; |
26 | | |
27 | 0 | cm::string_view GetName() const { return this->Name; } |
28 | | |
29 | | cm::string_view GetDisplayName() const |
30 | 0 | { |
31 | 0 | if (this->Name.empty()) { |
32 | 0 | return "<anonymous>"_s; |
33 | 0 | } |
34 | 0 | return this->Name; |
35 | 0 | } |
36 | | |
37 | | class Item |
38 | | { |
39 | | public: |
40 | 0 | virtual ~Item() = default; |
41 | | |
42 | | virtual std::string GetItemPath(std::string const& config) const = 0; |
43 | | |
44 | | virtual cmGeneratorTarget const* GetGeneratorTarget() const |
45 | 0 | { |
46 | 0 | return nullptr; |
47 | 0 | } |
48 | | |
49 | | virtual void AddPostExcludeFiles( |
50 | | std::string const& /*config*/, std::set<std::string>& /*files*/, |
51 | | cmInstallRuntimeDependencySet* /*set*/) const |
52 | 0 | { |
53 | 0 | } |
54 | | }; |
55 | | |
56 | | class TargetItem : public Item |
57 | | { |
58 | | public: |
59 | | TargetItem(cmInstallTargetGenerator* target) |
60 | 0 | : Target(target) |
61 | 0 | { |
62 | 0 | } |
63 | | |
64 | | std::string GetItemPath(std::string const& config) const override; |
65 | | |
66 | | cmGeneratorTarget const* GetGeneratorTarget() const override; |
67 | | |
68 | | void AddPostExcludeFiles( |
69 | | std::string const& config, std::set<std::string>& files, |
70 | | cmInstallRuntimeDependencySet* set) const override; |
71 | | |
72 | | private: |
73 | | cmInstallTargetGenerator* Target; |
74 | | }; |
75 | | |
76 | | class ImportedTargetItem : public Item |
77 | | { |
78 | | public: |
79 | | ImportedTargetItem(cmInstallImportedRuntimeArtifactsGenerator* target) |
80 | 0 | : Target(target) |
81 | 0 | { |
82 | 0 | } |
83 | | |
84 | | std::string GetItemPath(std::string const& config) const override; |
85 | | |
86 | | cmGeneratorTarget const* GetGeneratorTarget() const override; |
87 | | |
88 | | private: |
89 | | cmInstallImportedRuntimeArtifactsGenerator* Target; |
90 | | }; |
91 | | |
92 | | void AddExecutable(std::unique_ptr<Item> executable); |
93 | | void AddLibrary(std::unique_ptr<Item> library); |
94 | | void AddModule(std::unique_ptr<Item> module); |
95 | | bool AddBundleExecutable(std::unique_ptr<Item> bundleExecutable); |
96 | | |
97 | | void AddExecutable(cmInstallTargetGenerator* executable) |
98 | 0 | { |
99 | 0 | this->AddExecutable(cm::make_unique<TargetItem>(executable)); |
100 | 0 | } |
101 | | |
102 | | void AddLibrary(cmInstallTargetGenerator* library) |
103 | 0 | { |
104 | 0 | this->AddLibrary(cm::make_unique<TargetItem>(library)); |
105 | 0 | } |
106 | | |
107 | | void AddModule(cmInstallTargetGenerator* module) |
108 | 0 | { |
109 | 0 | this->AddModule(cm::make_unique<TargetItem>(module)); |
110 | 0 | } |
111 | | |
112 | | bool AddBundleExecutable(cmInstallTargetGenerator* bundleExecutable) |
113 | 0 | { |
114 | 0 | return this->AddBundleExecutable( |
115 | 0 | cm::make_unique<TargetItem>(bundleExecutable)); |
116 | 0 | } |
117 | | |
118 | | void AddExecutable(cmInstallImportedRuntimeArtifactsGenerator* executable) |
119 | 0 | { |
120 | 0 | this->AddExecutable(cm::make_unique<ImportedTargetItem>(executable)); |
121 | 0 | } |
122 | | |
123 | | void AddLibrary(cmInstallImportedRuntimeArtifactsGenerator* library) |
124 | 0 | { |
125 | 0 | this->AddLibrary(cm::make_unique<ImportedTargetItem>(library)); |
126 | 0 | } |
127 | | |
128 | | void AddModule(cmInstallImportedRuntimeArtifactsGenerator* module) |
129 | 0 | { |
130 | 0 | this->AddModule(cm::make_unique<ImportedTargetItem>(module)); |
131 | 0 | } |
132 | | |
133 | | bool AddBundleExecutable( |
134 | | cmInstallImportedRuntimeArtifactsGenerator* bundleExecutable) |
135 | 0 | { |
136 | 0 | return this->AddBundleExecutable( |
137 | 0 | cm::make_unique<ImportedTargetItem>(bundleExecutable)); |
138 | 0 | } |
139 | | |
140 | | std::vector<std::unique_ptr<Item>> const& GetExecutables() const |
141 | 0 | { |
142 | 0 | return this->Executables; |
143 | 0 | } |
144 | | |
145 | | std::vector<std::unique_ptr<Item>> const& GetLibraries() const |
146 | 0 | { |
147 | 0 | return this->Libraries; |
148 | 0 | } |
149 | | |
150 | | std::vector<std::unique_ptr<Item>> const& GetModules() const |
151 | 0 | { |
152 | 0 | return this->Modules; |
153 | 0 | } |
154 | | |
155 | 0 | Item* GetBundleExecutable() const { return this->BundleExecutable; } |
156 | | |
157 | | void GetInstallBuildDependencies( |
158 | | std::vector<cmGeneratorTarget const*>& dependencies) const; |
159 | | |
160 | | bool Empty() const |
161 | 0 | { |
162 | 0 | return this->Executables.empty() && this->Libraries.empty() && |
163 | 0 | this->Modules.empty(); |
164 | 0 | } |
165 | | |
166 | | private: |
167 | | std::string Name; |
168 | | std::vector<std::unique_ptr<Item>> Executables; |
169 | | std::vector<std::unique_ptr<Item>> Libraries; |
170 | | std::vector<std::unique_ptr<Item>> Modules; |
171 | | Item* BundleExecutable = nullptr; |
172 | | |
173 | | std::map<cmGeneratorTarget const*, std::set<cmGeneratorTarget const*>> |
174 | | TargetDepends; |
175 | | }; |