/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 void AddPostExcludeFiles( |
45 | | std::string const& /*config*/, std::set<std::string>& /*files*/, |
46 | | cmInstallRuntimeDependencySet* /*set*/) const |
47 | 0 | { |
48 | 0 | } |
49 | | }; |
50 | | |
51 | | class TargetItem : public Item |
52 | | { |
53 | | public: |
54 | | TargetItem(cmInstallTargetGenerator* target) |
55 | 0 | : Target(target) |
56 | 0 | { |
57 | 0 | } |
58 | | |
59 | | std::string GetItemPath(std::string const& config) const override; |
60 | | |
61 | | void AddPostExcludeFiles( |
62 | | std::string const& config, std::set<std::string>& files, |
63 | | cmInstallRuntimeDependencySet* set) const override; |
64 | | |
65 | | private: |
66 | | cmInstallTargetGenerator* Target; |
67 | | }; |
68 | | |
69 | | class ImportedTargetItem : public Item |
70 | | { |
71 | | public: |
72 | | ImportedTargetItem(cmInstallImportedRuntimeArtifactsGenerator* target) |
73 | 0 | : Target(target) |
74 | 0 | { |
75 | 0 | } |
76 | | |
77 | | std::string GetItemPath(std::string const& config) const override; |
78 | | |
79 | | private: |
80 | | cmInstallImportedRuntimeArtifactsGenerator* Target; |
81 | | }; |
82 | | |
83 | | void AddExecutable(std::unique_ptr<Item> executable); |
84 | | void AddLibrary(std::unique_ptr<Item> library); |
85 | | void AddModule(std::unique_ptr<Item> module); |
86 | | bool AddBundleExecutable(std::unique_ptr<Item> bundleExecutable); |
87 | | |
88 | | void AddExecutable(cmInstallTargetGenerator* executable) |
89 | 0 | { |
90 | 0 | this->AddExecutable(cm::make_unique<TargetItem>(executable)); |
91 | 0 | } |
92 | | |
93 | | void AddLibrary(cmInstallTargetGenerator* library) |
94 | 0 | { |
95 | 0 | this->AddLibrary(cm::make_unique<TargetItem>(library)); |
96 | 0 | } |
97 | | |
98 | | void AddModule(cmInstallTargetGenerator* module) |
99 | 0 | { |
100 | 0 | this->AddModule(cm::make_unique<TargetItem>(module)); |
101 | 0 | } |
102 | | |
103 | | bool AddBundleExecutable(cmInstallTargetGenerator* bundleExecutable) |
104 | 0 | { |
105 | 0 | return this->AddBundleExecutable( |
106 | 0 | cm::make_unique<TargetItem>(bundleExecutable)); |
107 | 0 | } |
108 | | |
109 | | void AddExecutable(cmInstallImportedRuntimeArtifactsGenerator* executable) |
110 | 0 | { |
111 | 0 | this->AddExecutable(cm::make_unique<ImportedTargetItem>(executable)); |
112 | 0 | } |
113 | | |
114 | | void AddLibrary(cmInstallImportedRuntimeArtifactsGenerator* library) |
115 | 0 | { |
116 | 0 | this->AddLibrary(cm::make_unique<ImportedTargetItem>(library)); |
117 | 0 | } |
118 | | |
119 | | void AddModule(cmInstallImportedRuntimeArtifactsGenerator* module) |
120 | 0 | { |
121 | 0 | this->AddModule(cm::make_unique<ImportedTargetItem>(module)); |
122 | 0 | } |
123 | | |
124 | | bool AddBundleExecutable( |
125 | | cmInstallImportedRuntimeArtifactsGenerator* bundleExecutable) |
126 | 0 | { |
127 | 0 | return this->AddBundleExecutable( |
128 | 0 | cm::make_unique<ImportedTargetItem>(bundleExecutable)); |
129 | 0 | } |
130 | | |
131 | | std::vector<std::unique_ptr<Item>> const& GetExecutables() const |
132 | 0 | { |
133 | 0 | return this->Executables; |
134 | 0 | } |
135 | | |
136 | | std::vector<std::unique_ptr<Item>> const& GetLibraries() const |
137 | 0 | { |
138 | 0 | return this->Libraries; |
139 | 0 | } |
140 | | |
141 | | std::vector<std::unique_ptr<Item>> const& GetModules() const |
142 | 0 | { |
143 | 0 | return this->Modules; |
144 | 0 | } |
145 | | |
146 | 0 | Item* GetBundleExecutable() const { return this->BundleExecutable; } |
147 | | |
148 | | bool Empty() const |
149 | 0 | { |
150 | 0 | return this->Executables.empty() && this->Libraries.empty() && |
151 | 0 | this->Modules.empty(); |
152 | 0 | } |
153 | | |
154 | | private: |
155 | | std::string Name; |
156 | | std::vector<std::unique_ptr<Item>> Executables; |
157 | | std::vector<std::unique_ptr<Item>> Libraries; |
158 | | std::vector<std::unique_ptr<Item>> Modules; |
159 | | Item* BundleExecutable = nullptr; |
160 | | |
161 | | std::map<cmGeneratorTarget const*, std::set<cmGeneratorTarget const*>> |
162 | | TargetDepends; |
163 | | }; |