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