/src/CMake/Source/cmGeneratorFileSet.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 <utility> |
12 | | #include <vector> |
13 | | |
14 | | #include "cmFileSetMetadata.h" |
15 | | #include "cmGeneratorExpression.h" |
16 | | #include "cmListFileCache.h" |
17 | | #include "cmTargetPropertyEntry.h" |
18 | | #include "cmValue.h" |
19 | | |
20 | | namespace cm { |
21 | | namespace GenEx { |
22 | | struct Context; |
23 | | } |
24 | | } |
25 | | |
26 | | struct cmGeneratorExpressionDAGChecker; |
27 | | |
28 | | class cmFileSet; |
29 | | class cmGeneratorTarget; |
30 | | |
31 | | class cmGeneratorFileSet |
32 | | { |
33 | | public: |
34 | | using TargetPropertyEntry = cm::TargetPropertyEntry; |
35 | | |
36 | | cmGeneratorFileSet(cmGeneratorTarget const*, cmFileSet const*); |
37 | 0 | ~cmGeneratorFileSet() = default; |
38 | | |
39 | | cmGeneratorFileSet(cmGeneratorFileSet&&) = default; |
40 | | cmGeneratorFileSet(cmGeneratorFileSet const&) = delete; |
41 | | cmGeneratorFileSet& operator=(cmGeneratorFileSet const&) = delete; |
42 | | |
43 | | std::string const& GetName() const; |
44 | | std::string const& GetType() const; |
45 | | cm::FileSetMetadata::Visibility GetVisibility() const; |
46 | | |
47 | | bool IsForSelf() const; |
48 | | bool IsForInterface() const; |
49 | | bool CanBeIncluded() const; |
50 | | |
51 | 0 | cmGeneratorTarget const* GetTarget() const { return this->Target; } |
52 | | bool BelongsTo(cmGeneratorTarget const* target) const |
53 | 0 | { |
54 | 0 | return this->Target == target; |
55 | 0 | } |
56 | | |
57 | 0 | cmFileSet const* GetFileSet() const { return this->FileSet; } |
58 | | |
59 | | cmValue GetProperty(std::string const& prop) const; |
60 | | |
61 | | std::vector<BT<std::string>> GetIncludeDirectories( |
62 | | std::string const& config, std::string const& lang) const; |
63 | | std::vector<BT<std::string>> GetInterfaceIncludeDirectories( |
64 | | std::string const& config, std::string const& lang) const; |
65 | | |
66 | | std::vector<BT<std::string>> GetCompileOptions( |
67 | | std::string const& config, std::string const& language) const; |
68 | | std::vector<BT<std::string>> GetInterfaceCompileOptions( |
69 | | std::string const& config, std::string const& language) const; |
70 | | |
71 | | std::vector<BT<std::string>> GetCompileDefinitions( |
72 | | std::string const& config, std::string const& language) const; |
73 | | std::vector<BT<std::string>> GetInterfaceCompileDefinitions( |
74 | | std::string const& config, std::string const& language) const; |
75 | | |
76 | | std::vector<BT<std::string>> const& GetDirectoryEntries() const; |
77 | | std::vector<BT<std::string>> const& GetFileEntries() const; |
78 | | |
79 | | std::vector<std::unique_ptr<TargetPropertyEntry>> GetSources( |
80 | | cm::GenEx::Context const& context, cmGeneratorTarget const* target, |
81 | | cmGeneratorExpressionDAGChecker* dagChecker = nullptr) const; |
82 | | |
83 | | using FileMap = std::map<std::string, std::vector<std::string>>; |
84 | | |
85 | | // returned value: |
86 | | // first: list of directories |
87 | | // second: is context sensitive |
88 | | std::pair<std::vector<std::string>, bool> GetDirectories( |
89 | | cm::GenEx::Context const& context, cmGeneratorTarget const* target, |
90 | | cmGeneratorExpressionDAGChecker* dagChecker = nullptr) const; |
91 | | // returned value: |
92 | | // first: list of files per directory |
93 | | // second: is context sensitive |
94 | | std::pair<FileMap, bool> GetFiles( |
95 | | cm::GenEx::Context const& context, cmGeneratorTarget const* target, |
96 | | cmGeneratorExpressionDAGChecker* dagChecker = nullptr) const; |
97 | | |
98 | | std::vector<std::unique_ptr<cmCompiledGeneratorExpression>> const& |
99 | | CompileFileEntries() const; |
100 | | |
101 | | std::vector<std::unique_ptr<cmCompiledGeneratorExpression>> const& |
102 | | CompileDirectoryEntries() const; |
103 | | |
104 | | std::vector<std::string> EvaluateDirectoryEntries( |
105 | | std::vector<std::unique_ptr<cmCompiledGeneratorExpression>> const& cges, |
106 | | cm::GenEx::Context const& context, cmGeneratorTarget const* target, |
107 | | cmGeneratorExpressionDAGChecker* dagChecker = nullptr) const; |
108 | | |
109 | | using EvaluateFileEntryFunction = |
110 | | std::function<void(std::string&&, std::string&&, std::string&&)>; |
111 | | |
112 | | // returned value: is context sensitive |
113 | | bool EvaluateFiles( |
114 | | cm::GenEx::Context const& context, cmGeneratorTarget const* target, |
115 | | EvaluateFileEntryFunction callback, |
116 | | cmGeneratorExpressionDAGChecker* dagChecker = nullptr) const; |
117 | | |
118 | | void EvaluateFileEntry( |
119 | | std::vector<std::string> const& dirs, EvaluateFileEntryFunction handler, |
120 | | std::unique_ptr<cmCompiledGeneratorExpression> const& cge, |
121 | | cm::GenEx::Context const& context, cmGeneratorTarget const* target, |
122 | | cmGeneratorExpressionDAGChecker* dagChecker = nullptr) const; |
123 | | |
124 | | void EvaluateFileEntry( |
125 | | std::vector<std::string> const& dirs, FileMap& filesPerDir, |
126 | | std::unique_ptr<cmCompiledGeneratorExpression> const& cge, |
127 | | cm::GenEx::Context const& context, cmGeneratorTarget const* target, |
128 | | cmGeneratorExpressionDAGChecker* dagChecker = nullptr) const; |
129 | | |
130 | | private: |
131 | | cmGeneratorTarget const* Target; |
132 | | cmFileSet const* FileSet; |
133 | | mutable std::vector<std::unique_ptr<cmCompiledGeneratorExpression>> |
134 | | CompiledDirectoryEntries; |
135 | | mutable std::vector<std::unique_ptr<cmCompiledGeneratorExpression>> |
136 | | CompiledFileEntries; |
137 | | |
138 | | using TargetPropertyEntries = |
139 | | std::vector<std::unique_ptr<TargetPropertyEntry>>; |
140 | | TargetPropertyEntries IncludeDirectories; |
141 | | TargetPropertyEntries InterfaceIncludeDirectories; |
142 | | TargetPropertyEntries CompileOptions; |
143 | | TargetPropertyEntries InterfaceCompileOptions; |
144 | | TargetPropertyEntries CompileDefinitions; |
145 | | TargetPropertyEntries InterfaceCompileDefinitions; |
146 | | |
147 | | using ConfigAndLanguage = std::pair<std::string, std::string>; |
148 | | using ConfigAndLanguageToBTStrings = |
149 | | std::map<ConfigAndLanguage, std::vector<BT<std::string>>>; |
150 | | mutable ConfigAndLanguageToBTStrings IncludeDirectoriesCache; |
151 | | mutable ConfigAndLanguageToBTStrings InterfaceIncludeDirectoriesCache; |
152 | | mutable ConfigAndLanguageToBTStrings CompileOptionsCache; |
153 | | mutable ConfigAndLanguageToBTStrings InterfaceCompileOptionsCache; |
154 | | mutable ConfigAndLanguageToBTStrings CompileDefinitionsCache; |
155 | | mutable ConfigAndLanguageToBTStrings InterfaceCompileDefinitionsCache; |
156 | | }; |