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