/src/CMake/Source/cmGeneratorFileSets.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 "cmConfigure.h" // IWYU pragma: keep |
6 | | |
7 | | #include <functional> |
8 | | #include <map> |
9 | | #include <memory> |
10 | | #include <string> |
11 | | #include <unordered_map> |
12 | | #include <unordered_set> |
13 | | #include <vector> |
14 | | |
15 | | #include <cm/string_view> |
16 | | |
17 | | #include "cmTargetPropertyEntry.h" |
18 | | |
19 | | namespace cm { |
20 | | namespace GenEx { |
21 | | struct Context; |
22 | | struct Evaluation; |
23 | | } |
24 | | } |
25 | | |
26 | | struct cmGeneratorExpressionDAGChecker; |
27 | | |
28 | | class cmSourceFile; |
29 | | class cmGeneratorTarget; |
30 | | class cmGeneratorFileSet; |
31 | | class cmLocalGenerator; |
32 | | |
33 | | class cmGeneratorFileSets |
34 | | { |
35 | | public: |
36 | | using TargetPropertyEntry = cm::TargetPropertyEntry; |
37 | | |
38 | | cmGeneratorFileSets(cmGeneratorTarget* target, cmLocalGenerator* lg); |
39 | | ~cmGeneratorFileSets(); |
40 | | |
41 | | cmGeneratorFileSets(cmGeneratorFileSets const&) = delete; |
42 | | cmGeneratorFileSets& operator=(cmGeneratorFileSets const&) = delete; |
43 | | |
44 | 0 | bool Empty() const { return this->FileSets.empty(); } |
45 | | |
46 | | std::vector<cm::string_view> GetFileSetTypes() const; |
47 | | std::vector<cm::string_view> GetInterfaceFileSetTypes() const; |
48 | | |
49 | | std::vector<cmGeneratorFileSet const*> const& GetAllFileSets() const; |
50 | | std::vector<cmGeneratorFileSet const*> const& GetFileSets( |
51 | | cm::string_view type) const; |
52 | | std::vector<cmGeneratorFileSet const*> const& GetInterfaceFileSets( |
53 | | cm::string_view type) const; |
54 | | |
55 | | cmGeneratorFileSet const* GetFileSet(std::string const& name) const; |
56 | | |
57 | | std::unordered_set<cmGeneratorFileSet const*> const& GetAllFileSetsForSource( |
58 | | std::string const& config, std::string const& file) const; |
59 | | std::unordered_set<cmGeneratorFileSet const*> const& GetAllFileSetsForSource( |
60 | | std::string const& config, cmSourceFile const* sf) const; |
61 | | |
62 | | // returns the first FileSet of the set |
63 | | cmGeneratorFileSet const* GetFileSetForSource(std::string const& config, |
64 | | std::string const& file) const; |
65 | | cmGeneratorFileSet const* GetFileSetForSource(std::string const& config, |
66 | | cmSourceFile const* sf) const; |
67 | | |
68 | | std::vector<std::unique_ptr<TargetPropertyEntry>> GetSources( |
69 | | cm::GenEx::Context const& context, cmGeneratorTarget const* target, |
70 | | cmGeneratorExpressionDAGChecker* dagChecker = nullptr) const; |
71 | | std::vector<std::unique_ptr<TargetPropertyEntry>> GetSources( |
72 | | std::string type, cm::GenEx::Context const& context, |
73 | | cmGeneratorTarget const* target, |
74 | | cmGeneratorExpressionDAGChecker* dagChecker = nullptr) const; |
75 | | |
76 | | std::vector<std::unique_ptr<TargetPropertyEntry>> GetInterfaceSources( |
77 | | cm::GenEx::Context const& context, cmGeneratorTarget const* target, |
78 | | cmGeneratorExpressionDAGChecker* dagChecker = nullptr) const; |
79 | | std::vector<std::unique_ptr<TargetPropertyEntry>> GetInterfaceSources( |
80 | | std::string type, cm::GenEx::Context const& context, |
81 | | cmGeneratorTarget const* target, |
82 | | cmGeneratorExpressionDAGChecker* dagChecker = nullptr) const; |
83 | | |
84 | | std::string EvaluateInterfaceProperty( |
85 | | cm::string_view type, std::string const& prop, cm::GenEx::Evaluation* eval, |
86 | | cmGeneratorExpressionDAGChecker* dagCheckerParent) const; |
87 | | |
88 | | private: |
89 | | std::vector<std::unique_ptr<cm::TargetPropertyEntry>> GetSources( |
90 | | std::function<bool(cmGeneratorFileSet const*)> include, |
91 | | cm::GenEx::Context const& context, cmGeneratorTarget const* target, |
92 | | cmGeneratorExpressionDAGChecker* dagChecker) const; |
93 | | |
94 | | // file sets indexed by name |
95 | | std::map<std::string, std::unique_ptr<cmGeneratorFileSet>> FileSets; |
96 | | std::vector<cmGeneratorFileSet const*> AllFileSets; |
97 | | // list of private file sets indexed by type |
98 | | std::unordered_map<cm::string_view, std::vector<cmGeneratorFileSet const*>> |
99 | | SelfFileSets; |
100 | | // list of interface file sets indexed by type |
101 | | std::unordered_map<cm::string_view, std::vector<cmGeneratorFileSet const*>> |
102 | | InterfaceFileSets; |
103 | | |
104 | | mutable std::unordered_map<std::string, bool> MaybeInterfacePropertyExists; |
105 | | bool MaybeHaveInterfaceProperty(cm::string_view type, |
106 | | std::string const& prop, |
107 | | cm::GenEx::Evaluation* eval) const; |
108 | | |
109 | | struct InfoByConfig |
110 | | { |
111 | | bool BuiltCache = false; |
112 | | std::map<std::string, std::unordered_set<cmGeneratorFileSet const*>> |
113 | | FileSetCache; |
114 | | std::map<std::string, std::unordered_set<cmGeneratorFileSet const*>> |
115 | | InterfaceFileSetCache; |
116 | | }; |
117 | | mutable std::map<std::string, InfoByConfig> Configs; |
118 | | |
119 | | void BuildInfoCache(std::string const& config) const; |
120 | | |
121 | | cmGeneratorTarget* Target; |
122 | | cmLocalGenerator* LocalGenerator; |
123 | | }; |