1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#pragma once
#include "cmConfigure.h" // IWYU pragma: keep
#include <cstddef>
#include <limits>
#include <memory>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cm/string_view>
#include "cmFilePathChecksum.h"
#include "cmQtAutoGen.h"
class cmGeneratorTarget;
class cmGlobalGenerator;
class cmLocalGenerator;
class cmMakefile;
class cmQtAutoGenGlobalInitializer;
class cmSourceFile;
class cmTarget;
/** \class cmQtAutoGenerator
* \brief Initializes the QtAutoGen generators
*/
class cmQtAutoGenInitializer : public cmQtAutoGen
{
public:
/** String value with per configuration variants. */
class ConfigString
{
public:
std::string Default;
std::unordered_map<std::string, std::string> Config;
};
/** String values with per configuration variants. */
template <typename C>
class ConfigStrings
{
public:
C Default;
std::unordered_map<std::string, C> Config;
};
/** rcc job. */
class Qrc
{
public:
std::string LockFile;
std::string QrcFile;
std::string QrcName;
std::string QrcPathChecksum;
std::string InfoFile;
ConfigString SettingsFile;
std::string OutputFile;
bool Generated = false;
bool Unique = false;
std::vector<std::string> Options;
std::vector<std::string> Resources;
};
/** moc and/or uic file. */
struct MUFile
{
std::string FullPath;
cmSourceFile* SF = nullptr;
std::vector<size_t> Configs;
bool Generated = false;
bool SkipMoc = false;
bool SkipUic = false;
bool MocIt = false;
bool UicIt = false;
};
using MUFileHandle = std::unique_ptr<MUFile>;
/** Abstract moc/uic/rcc generator variables base class. */
struct GenVarsT
{
bool Enabled = false;
// Generator type/name
GenT Gen;
cm::string_view GenNameUpper;
// Executable
std::string ExecutableTargetName;
cmGeneratorTarget* ExecutableTarget = nullptr;
std::string Executable;
CompilerFeaturesHandle ExecutableFeatures;
GenVarsT(GenT gen)
: Gen(gen)
, GenNameUpper(cmQtAutoGen::GeneratorNameUpper(gen))
{
}
};
/** @param mocExecutable The file path to the moc executable. Will be used as
fallback to query the version
@return The detected Qt version and the required Qt major version. */
static std::pair<IntegerVersion, unsigned int> GetQtVersion(
cmGeneratorTarget const* genTarget, std::string mocExecutable);
cmQtAutoGenInitializer(cmQtAutoGenGlobalInitializer* globalInitializer,
cmGeneratorTarget* genTarget,
IntegerVersion const& qtVersion, bool mocEnabled,
bool uicEnabled, bool rccEnabled,
bool globalAutogenTarget, bool globalAutoRccTarget);
bool InitCustomTargets();
bool SetupCustomTargets();
private:
/** If moc or uic is enabled, the autogen target will be generated. */
bool MocOrUicEnabled() const
{
return (this->Moc.Enabled || this->Uic.Enabled);
}
bool InitMoc();
bool InitUic();
bool InitRcc();
bool InitScanFiles();
bool InitAutogenTarget();
bool InitRccTargets();
bool SetupWriteAutogenInfo();
bool SetupWriteRccInfo();
cmSourceFile* RegisterGeneratedSource(std::string const& filename);
cmSourceFile* AddGeneratedSource(std::string const& filename,
GenVarsT const& genVars,
bool prepend = false);
void AddGeneratedSource(ConfigString const& filename,
GenVarsT const& genVars, bool prepend = false);
void AddToSourceGroup(std::string const& fileName,
cm::string_view genNameUpper);
void AddCleanFile(std::string const& fileName);
void ConfigFileNames(ConfigString& configString, cm::string_view prefix,
cm::string_view suffix);
void ConfigFileNamesAndGenex(ConfigString& configString, std::string& genex,
cm::string_view prefix, cm::string_view suffix);
void ConfigFileClean(ConfigString& configString);
std::string GetMocBuildPath(MUFile const& muf);
bool GetQtExecutable(GenVarsT& genVars, const std::string& executable,
bool ignoreMissingTarget) const;
void handleSkipPch(cmSourceFile* sf);
cmQtAutoGenGlobalInitializer* GlobalInitializer = nullptr;
cmGeneratorTarget* GenTarget = nullptr;
cmGlobalGenerator* GlobalGen = nullptr;
cmLocalGenerator* LocalGen = nullptr;
cmMakefile* Makefile = nullptr;
cmFilePathChecksum const PathCheckSum;
// -- Configuration
IntegerVersion QtVersion;
unsigned int Verbosity = 0;
bool MultiConfig = false;
bool CrossConfig = false;
bool CMP0071Accept = false;
bool CMP0071Warn = false;
bool CMP0100Accept = false;
bool CMP0100Warn = false;
std::string ConfigDefault;
std::vector<std::string> ConfigsList;
std::string TargetsFolder;
/** Common directories. */
struct
{
std::string Info;
std::string Build;
std::string RelativeBuild;
std::string Work;
ConfigString Include;
std::string IncludeGenExp;
} Dir;
/** Autogen target variables. */
struct
{
std::string Name;
bool GlobalTarget = false;
// Settings
unsigned int Parallel = 1;
unsigned int MaxCommandLineLength =
std::numeric_limits<unsigned int>::max();
// Configuration files
std::string InfoFile;
ConfigString SettingsFile;
ConfigString ParseCacheFile;
// Dependencies
bool DependOrigin = false;
std::set<std::string> DependFiles;
std::set<cmTarget*> DependTargets;
std::string DepFile;
std::string DepFileRuleName;
// Sources to process
std::unordered_map<cmSourceFile*, MUFileHandle> Headers;
std::unordered_map<cmSourceFile*, MUFileHandle> Sources;
std::vector<MUFile*> FilesGenerated;
std::vector<cmSourceFile*> CMP0100HeadersWarn;
} AutogenTarget;
/** moc variables. */
struct MocT : public GenVarsT
{
MocT()
: GenVarsT(GenT::MOC)
{
}
bool RelaxedMode = false;
bool PathPrefix = false;
ConfigString CompilationFile;
std::string CompilationFileGenex;
// Compiler implicit pre defines
std::vector<std::string> PredefsCmd;
ConfigString PredefsFile;
// Defines
ConfigStrings<std::set<std::string>> Defines;
// Includes
ConfigStrings<std::vector<std::string>> Includes;
// Options
std::vector<std::string> Options;
// Filters
std::vector<std::string> MacroNames;
std::vector<std::pair<std::string, std::string>> DependFilters;
// Utility
std::unordered_set<std::string> EmittedBuildPaths;
} Moc;
/** uic variables. */
struct UicT : public GenVarsT
{
using UiFileT = std::pair<std::string, std::vector<std::string>>;
UicT()
: GenVarsT(GenT::UIC)
{
}
std::set<std::string> SkipUi;
std::vector<std::string> UiFilesNoOptions;
std::vector<UiFileT> UiFilesWithOptions;
ConfigStrings<std::vector<std::string>> Options;
std::vector<std::string> SearchPaths;
std::vector<std::pair<ConfigString /*ui header*/, std::string /*genex*/>>
UiHeaders;
} Uic;
/** rcc variables. */
struct RccT : public GenVarsT
{
RccT()
: GenVarsT(GenT::RCC)
{
}
bool GlobalTarget = false;
std::vector<Qrc> Qrcs;
} Rcc;
};
|