Autogen: Wrap moc/uic/rcc related variables in structs

This commit is contained in:
Sebastian Holtermann
2018-07-11 13:54:46 +02:00
parent c6a8002827
commit 189f723509
2 changed files with 120 additions and 109 deletions

View File

@@ -182,12 +182,13 @@ cmQtAutoGenInitializer::cmQtAutoGenInitializer(
cmGeneratorTarget* target, bool mocEnabled, bool uicEnabled, bool rccEnabled, cmGeneratorTarget* target, bool mocEnabled, bool uicEnabled, bool rccEnabled,
std::string const& qtVersionMajor) std::string const& qtVersionMajor)
: Target(target) : Target(target)
, MocEnabled(mocEnabled)
, UicEnabled(uicEnabled)
, RccEnabled(rccEnabled)
, MultiConfig(false) , MultiConfig(false)
, QtVersionMajor(qtVersionMajor) , QtVersionMajor(qtVersionMajor)
{ {
Moc.Enabled = mocEnabled;
Uic.Enabled = uicEnabled;
Rcc.Enabled = rccEnabled;
this->QtVersionMinor = this->QtVersionMinor =
cmQtAutoGenInitializer::GetQtMinorVersion(target, this->QtVersionMajor); cmQtAutoGenInitializer::GetQtMinorVersion(target, this->QtVersionMajor);
} }
@@ -300,15 +301,15 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
} }
// Add moc compilation to generated files list // Add moc compilation to generated files list
if (this->MocEnabled) { if (this->Moc.Enabled) {
std::string mocsComp = this->DirBuild + "/mocs_compilation.cpp"; std::string mocsComp = this->DirBuild + "/mocs_compilation.cpp";
this->AddGeneratedSource(mocsComp, GeneratorT::MOC); this->AddGeneratedSource(mocsComp, GeneratorT::MOC);
autogenProvides.push_back(std::move(mocsComp)); autogenProvides.push_back(std::move(mocsComp));
} }
// Add autogen includes directory to the origin target INCLUDE_DIRECTORIES // Add autogen includes directory to the origin target INCLUDE_DIRECTORIES
if (this->MocEnabled || this->UicEnabled || if (this->Moc.Enabled || this->Uic.Enabled ||
(this->RccEnabled && this->MultiConfig)) { (this->Rcc.Enabled && this->MultiConfig)) {
std::string includeDir = this->DirBuild; std::string includeDir = this->DirBuild;
includeDir += "/include"; includeDir += "/include";
if (this->MultiConfig) { if (this->MultiConfig) {
@@ -318,7 +319,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
} }
// Acquire rcc executable and features // Acquire rcc executable and features
if (this->RccEnabled) { if (this->Rcc.Enabled) {
if (!GetRccExecutable()) { if (!GetRccExecutable()) {
return false; return false;
} }
@@ -339,14 +340,14 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
std::string const& fPath = sf->GetFullPath(); std::string const& fPath = sf->GetFullPath();
std::string const& ext = sf->GetExtension(); std::string const& ext = sf->GetExtension();
// Register generated files that will be scanned by moc or uic // Register generated files that will be scanned by moc or uic
if (this->MocEnabled || this->UicEnabled) { if (this->Moc.Enabled || this->Uic.Enabled) {
cmSystemTools::FileFormat const fileType = cmSystemTools::FileFormat const fileType =
cmSystemTools::GetFileFormat(ext.c_str()); cmSystemTools::GetFileFormat(ext.c_str());
if ((fileType == cmSystemTools::CXX_FILE_FORMAT) || if ((fileType == cmSystemTools::CXX_FILE_FORMAT) ||
(fileType == cmSystemTools::HEADER_FILE_FORMAT)) { (fileType == cmSystemTools::HEADER_FILE_FORMAT)) {
std::string const absPath = cmSystemTools::GetRealPath(fPath); std::string const absPath = cmSystemTools::GetRealPath(fPath);
if ((this->MocEnabled && !sf->GetPropertyAsBool("SKIP_AUTOMOC")) || if ((this->Moc.Enabled && !sf->GetPropertyAsBool("SKIP_AUTOMOC")) ||
(this->UicEnabled && !sf->GetPropertyAsBool("SKIP_AUTOUIC"))) { (this->Uic.Enabled && !sf->GetPropertyAsBool("SKIP_AUTOUIC"))) {
// Register source // Register source
const bool generated = sf->GetPropertyAsBool("GENERATED"); const bool generated = sf->GetPropertyAsBool("GENERATED");
if (fileType == cmSystemTools::HEADER_FILE_FORMAT) { if (fileType == cmSystemTools::HEADER_FILE_FORMAT) {
@@ -366,7 +367,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
} }
} }
// Register rcc enabled files // Register rcc enabled files
if (this->RccEnabled && (ext == qrcExt) && if (this->Rcc.Enabled && (ext == qrcExt) &&
!sf->GetPropertyAsBool("SKIP_AUTORCC")) { !sf->GetPropertyAsBool("SKIP_AUTORCC")) {
// Register qrc file // Register qrc file
{ {
@@ -382,7 +383,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
cmSystemTools::ExpandListArgument(opts, qrc.Options); cmSystemTools::ExpandListArgument(opts, qrc.Options);
} }
} }
this->Qrcs.push_back(std::move(qrc)); this->Rcc.Qrcs.push_back(std::move(qrc));
} }
} }
} }
@@ -393,7 +394,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
this->Target->ClearSourcesCache(); this->Target->ClearSourcesCache();
} }
// Read skip files from makefile sources // Read skip files from makefile sources
if (this->MocEnabled || this->UicEnabled) { if (this->Moc.Enabled || this->Uic.Enabled) {
std::string pathError; std::string pathError;
for (cmSourceFile* sf : makefile->GetSourceFiles()) { for (cmSourceFile* sf : makefile->GetSourceFiles()) {
// sf->GetExtension() is only valid after sf->GetFullPath() ... // sf->GetExtension() is only valid after sf->GetFullPath() ...
@@ -411,17 +412,17 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
continue; continue;
} }
const bool skipAll = sf->GetPropertyAsBool("SKIP_AUTOGEN"); const bool skipAll = sf->GetPropertyAsBool("SKIP_AUTOGEN");
const bool mocSkip = const bool mocSkip = this->Moc.Enabled &&
this->MocEnabled && (skipAll || sf->GetPropertyAsBool("SKIP_AUTOMOC")); (skipAll || sf->GetPropertyAsBool("SKIP_AUTOMOC"));
const bool uicSkip = const bool uicSkip = this->Uic.Enabled &&
this->UicEnabled && (skipAll || sf->GetPropertyAsBool("SKIP_AUTOUIC")); (skipAll || sf->GetPropertyAsBool("SKIP_AUTOUIC"));
if (mocSkip || uicSkip) { if (mocSkip || uicSkip) {
std::string const absFile = cmSystemTools::GetRealPath(fPath); std::string const absFile = cmSystemTools::GetRealPath(fPath);
if (mocSkip) { if (mocSkip) {
this->MocSkip.insert(absFile); this->Moc.Skip.insert(absFile);
} }
if (uicSkip) { if (uicSkip) {
this->UicSkip.insert(absFile); this->Uic.Skip.insert(absFile);
} }
} }
} }
@@ -466,13 +467,13 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
msg += "\n"; msg += "\n";
std::string tools; std::string tools;
std::string property; std::string property;
if (this->MocEnabled && this->UicEnabled) { if (this->Moc.Enabled && this->Uic.Enabled) {
tools = "AUTOMOC and AUTOUIC"; tools = "AUTOMOC and AUTOUIC";
property = "SKIP_AUTOGEN"; property = "SKIP_AUTOGEN";
} else if (this->MocEnabled) { } else if (this->Moc.Enabled) {
tools = "AUTOMOC"; tools = "AUTOMOC";
property = "SKIP_AUTOMOC"; property = "SKIP_AUTOMOC";
} else if (this->UicEnabled) { } else if (this->Uic.Enabled) {
tools = "AUTOUIC"; tools = "AUTOUIC";
property = "SKIP_AUTOUIC"; property = "SKIP_AUTOUIC";
} }
@@ -502,13 +503,13 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
generatedHeaders.clear(); generatedHeaders.clear();
} }
// Sort headers and sources // Sort headers and sources
if (this->MocEnabled || this->UicEnabled) { if (this->Moc.Enabled || this->Uic.Enabled) {
std::sort(this->Headers.begin(), this->Headers.end()); std::sort(this->Headers.begin(), this->Headers.end());
std::sort(this->Sources.begin(), this->Sources.end()); std::sort(this->Sources.begin(), this->Sources.end());
} }
// Process qrc files // Process qrc files
if (!this->Qrcs.empty()) { if (!this->Rcc.Qrcs.empty()) {
const bool QtV5 = (this->QtVersionMajor == "5"); const bool QtV5 = (this->QtVersionMajor == "5");
// Target rcc options // Target rcc options
std::vector<std::string> optionsTarget; std::vector<std::string> optionsTarget;
@@ -516,9 +517,9 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
this->Target->GetSafeProperty("AUTORCC_OPTIONS"), optionsTarget); this->Target->GetSafeProperty("AUTORCC_OPTIONS"), optionsTarget);
// Check if file name is unique // Check if file name is unique
for (Qrc& qrc : this->Qrcs) { for (Qrc& qrc : this->Rcc.Qrcs) {
qrc.Unique = true; qrc.Unique = true;
for (Qrc const& qrc2 : this->Qrcs) { for (Qrc const& qrc2 : this->Rcc.Qrcs) {
if ((&qrc != &qrc2) && (qrc.QrcName == qrc2.QrcName)) { if ((&qrc != &qrc2) && (qrc.QrcName == qrc2.QrcName)) {
qrc.Unique = false; qrc.Unique = false;
break; break;
@@ -528,7 +529,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
// Path checksum and file names // Path checksum and file names
{ {
cmFilePathChecksum const fpathCheckSum(makefile); cmFilePathChecksum const fpathCheckSum(makefile);
for (Qrc& qrc : this->Qrcs) { for (Qrc& qrc : this->Rcc.Qrcs) {
qrc.PathChecksum = fpathCheckSum.getPart(qrc.QrcFile); qrc.PathChecksum = fpathCheckSum.getPart(qrc.QrcFile);
// RCC output file name // RCC output file name
{ {
@@ -559,7 +560,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
} }
} }
// RCC options // RCC options
for (Qrc& qrc : this->Qrcs) { for (Qrc& qrc : this->Rcc.Qrcs) {
// Target options // Target options
std::vector<std::string> opts = optionsTarget; std::vector<std::string> opts = optionsTarget;
// Merge computed "-name XYZ" option // Merge computed "-name XYZ" option
@@ -580,7 +581,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
RccMergeOptions(opts, qrc.Options, QtV5); RccMergeOptions(opts, qrc.Options, QtV5);
qrc.Options = std::move(opts); qrc.Options = std::move(opts);
} }
for (Qrc& qrc : this->Qrcs) { for (Qrc& qrc : this->Rcc.Qrcs) {
// Register file at target // Register file at target
this->AddGeneratedSource(qrc.RccFile, GeneratorT::RCC); this->AddGeneratedSource(qrc.RccFile, GeneratorT::RCC);
@@ -676,7 +677,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
} }
// Create _autogen target // Create _autogen target
if (this->MocEnabled || this->UicEnabled) { if (this->Moc.Enabled || this->Uic.Enabled) {
// Add user defined autogen target dependencies // Add user defined autogen target dependencies
{ {
std::string const deps = std::string const deps =
@@ -700,10 +701,10 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
std::string autogenComment; std::string autogenComment;
{ {
std::string tools; std::string tools;
if (this->MocEnabled) { if (this->Moc.Enabled) {
tools += "MOC"; tools += "MOC";
} }
if (this->UicEnabled) { if (this->Uic.Enabled) {
if (!tools.empty()) { if (!tools.empty()) {
tools += " and "; tools += " and ";
} }
@@ -847,11 +848,11 @@ bool cmQtAutoGenInitializer::SetupCustomTargets()
} }
// Generate autogen target info file // Generate autogen target info file
if (this->MocEnabled || this->UicEnabled) { if (this->Moc.Enabled || this->Uic.Enabled) {
if (this->MocEnabled) { if (this->Moc.Enabled) {
this->SetupCustomTargetsMoc(); this->SetupCustomTargetsMoc();
} }
if (this->UicEnabled) { if (this->Uic.Enabled) {
this->SetupCustomTargetsUic(); this->SetupCustomTargetsUic();
} }
@@ -938,16 +939,16 @@ bool cmQtAutoGenInitializer::SetupCustomTargets()
ofs << "# Qt\n"; ofs << "# Qt\n";
CWrite("AM_QT_VERSION_MAJOR", this->QtVersionMajor); CWrite("AM_QT_VERSION_MAJOR", this->QtVersionMajor);
CWrite("AM_QT_MOC_EXECUTABLE", this->MocExecutable); CWrite("AM_QT_MOC_EXECUTABLE", this->Moc.Executable);
CWrite("AM_QT_UIC_EXECUTABLE", this->UicExecutable); CWrite("AM_QT_UIC_EXECUTABLE", this->Uic.Executable);
if (this->MocEnabled) { if (this->Moc.Enabled) {
ofs << "# MOC settings\n"; ofs << "# MOC settings\n";
CWriteSet("AM_MOC_SKIP", this->MocSkip); CWriteSet("AM_MOC_SKIP", this->Moc.Skip);
CWrite("AM_MOC_DEFINITIONS", this->MocDefines); CWrite("AM_MOC_DEFINITIONS", this->Moc.Defines);
CWriteMap("AM_MOC_DEFINITIONS", this->MocDefinesConfig); CWriteMap("AM_MOC_DEFINITIONS", this->Moc.ConfigDefines);
CWrite("AM_MOC_INCLUDES", this->MocIncludes); CWrite("AM_MOC_INCLUDES", this->Moc.Includes);
CWriteMap("AM_MOC_INCLUDES", this->MocIncludesConfig); CWriteMap("AM_MOC_INCLUDES", this->Moc.ConfigIncludes);
CWrite("AM_MOC_OPTIONS", CWrite("AM_MOC_OPTIONS",
this->Target->GetSafeProperty("AUTOMOC_MOC_OPTIONS")); this->Target->GetSafeProperty("AUTOMOC_MOC_OPTIONS"));
CWrite("AM_MOC_RELAXED_MODE", MfDef("CMAKE_AUTOMOC_RELAXED_MODE")); CWrite("AM_MOC_RELAXED_MODE", MfDef("CMAKE_AUTOMOC_RELAXED_MODE"));
@@ -955,17 +956,17 @@ bool cmQtAutoGenInitializer::SetupCustomTargets()
this->Target->GetSafeProperty("AUTOMOC_MACRO_NAMES")); this->Target->GetSafeProperty("AUTOMOC_MACRO_NAMES"));
CWrite("AM_MOC_DEPEND_FILTERS", CWrite("AM_MOC_DEPEND_FILTERS",
this->Target->GetSafeProperty("AUTOMOC_DEPEND_FILTERS")); this->Target->GetSafeProperty("AUTOMOC_DEPEND_FILTERS"));
CWrite("AM_MOC_PREDEFS_CMD", this->MocPredefsCmd); CWrite("AM_MOC_PREDEFS_CMD", this->Moc.PredefsCmd);
} }
if (this->UicEnabled) { if (this->Uic.Enabled) {
ofs << "# UIC settings\n"; ofs << "# UIC settings\n";
CWriteSet("AM_UIC_SKIP", this->UicSkip); CWriteSet("AM_UIC_SKIP", this->Uic.Skip);
CWrite("AM_UIC_TARGET_OPTIONS", this->UicOptions); CWrite("AM_UIC_TARGET_OPTIONS", this->Uic.Options);
CWriteMap("AM_UIC_TARGET_OPTIONS", this->UicOptionsConfig); CWriteMap("AM_UIC_TARGET_OPTIONS", this->Uic.ConfigOptions);
CWriteList("AM_UIC_OPTIONS_FILES", this->UicFileFiles); CWriteList("AM_UIC_OPTIONS_FILES", this->Uic.FileFiles);
CWriteNestedLists("AM_UIC_OPTIONS_OPTIONS", this->UicFileOptions); CWriteNestedLists("AM_UIC_OPTIONS_OPTIONS", this->Uic.FileOptions);
CWriteList("AM_UIC_SEARCH_PATHS", this->UicSearchPaths); CWriteList("AM_UIC_SEARCH_PATHS", this->Uic.SearchPaths);
} }
} else { } else {
std::string err = "AutoGen: Could not write file "; std::string err = "AutoGen: Could not write file ";
@@ -976,8 +977,8 @@ bool cmQtAutoGenInitializer::SetupCustomTargets()
} }
// Generate auto RCC info files // Generate auto RCC info files
if (this->RccEnabled) { if (this->Rcc.Enabled) {
for (Qrc const& qrc : this->Qrcs) { for (Qrc const& qrc : this->Rcc.Qrcs) {
// Register rcc info file as generated // Register rcc info file as generated
makefile->AddCMakeOutputFile(qrc.InfoFile); makefile->AddCMakeOutputFile(qrc.InfoFile);
@@ -1024,8 +1025,8 @@ bool cmQtAutoGenInitializer::SetupCustomTargets()
} }
ofs << "# Rcc executable\n"; ofs << "# Rcc executable\n";
CWrite("ARCC_RCC_EXECUTABLE", this->RccExecutable); CWrite("ARCC_RCC_EXECUTABLE", this->Rcc.Executable);
CWrite("ARCC_RCC_LIST_OPTIONS", cmJoin(this->RccListOptions, ";")); CWrite("ARCC_RCC_LIST_OPTIONS", cmJoin(this->Rcc.ListOptions, ";"));
ofs << "# Rcc job\n"; ofs << "# Rcc job\n";
CWrite("ARCC_LOCK_FILE", qrc.LockFile); CWrite("ARCC_LOCK_FILE", qrc.LockFile);
@@ -1055,7 +1056,7 @@ bool cmQtAutoGenInitializer::SetupCustomTargetsMoc()
// Moc predefs command // Moc predefs command
if (this->Target->GetPropertyAsBool("AUTOMOC_COMPILER_PREDEFINES") && if (this->Target->GetPropertyAsBool("AUTOMOC_COMPILER_PREDEFINES") &&
this->QtVersionGreaterOrEqual(5, 8)) { this->QtVersionGreaterOrEqual(5, 8)) {
this->MocPredefsCmd = this->Moc.PredefsCmd =
makefile->GetSafeDefinition("CMAKE_CXX_COMPILER_PREDEFINES_COMMAND"); makefile->GetSafeDefinition("CMAKE_CXX_COMPILER_PREDEFINES_COMMAND");
} }
@@ -1079,20 +1080,20 @@ bool cmQtAutoGenInitializer::SetupCustomTargetsMoc()
}; };
// Default configuration settings // Default configuration settings
this->MocIncludes = GetIncludeDirs(this->ConfigDefault); this->Moc.Includes = GetIncludeDirs(this->ConfigDefault);
this->MocDefines = GetCompileDefinitions(this->ConfigDefault); this->Moc.Defines = GetCompileDefinitions(this->ConfigDefault);
// Other configuration settings // Other configuration settings
for (std::string const& cfg : this->ConfigsList) { for (std::string const& cfg : this->ConfigsList) {
{ {
std::string const configIncludeDirs = GetIncludeDirs(cfg); std::string const configIncludeDirs = GetIncludeDirs(cfg);
if (configIncludeDirs != this->MocIncludes) { if (configIncludeDirs != this->Moc.Includes) {
this->MocIncludesConfig[cfg] = configIncludeDirs; this->Moc.ConfigIncludes[cfg] = configIncludeDirs;
} }
} }
{ {
std::string const configCompileDefs = GetCompileDefinitions(cfg); std::string const configCompileDefs = GetCompileDefinitions(cfg);
if (configCompileDefs != this->MocDefines) { if (configCompileDefs != this->Moc.Defines) {
this->MocDefinesConfig[cfg] = configCompileDefs; this->Moc.ConfigDefines[cfg] = configCompileDefs;
} }
} }
} }
@@ -1114,9 +1115,9 @@ bool cmQtAutoGenInitializer::SetupCustomTargetsUic()
std::string const usp = std::string const usp =
this->Target->GetSafeProperty("AUTOUIC_SEARCH_PATHS"); this->Target->GetSafeProperty("AUTOUIC_SEARCH_PATHS");
if (!usp.empty()) { if (!usp.empty()) {
cmSystemTools::ExpandListArgument(usp, this->UicSearchPaths); cmSystemTools::ExpandListArgument(usp, this->Uic.SearchPaths);
std::string const srcDir = makefile->GetCurrentSourceDirectory(); std::string const srcDir = makefile->GetCurrentSourceDirectory();
for (std::string& path : this->UicSearchPaths) { for (std::string& path : this->Uic.SearchPaths) {
path = cmSystemTools::CollapseFullPath(path, srcDir); path = cmSystemTools::CollapseFullPath(path, srcDir);
} }
} }
@@ -1130,13 +1131,13 @@ bool cmQtAutoGenInitializer::SetupCustomTargetsUic()
}; };
// Default settings // Default settings
this->UicOptions = UicGetOpts(this->ConfigDefault); this->Uic.Options = UicGetOpts(this->ConfigDefault);
// Configuration specific settings // Configuration specific settings
for (std::string const& cfg : this->ConfigsList) { for (std::string const& cfg : this->ConfigsList) {
std::string const configUicOpts = UicGetOpts(cfg); std::string const configUicOpts = UicGetOpts(cfg);
if (configUicOpts != this->UicOptions) { if (configUicOpts != this->Uic.Options) {
this->UicOptionsConfig[cfg] = configUicOpts; this->Uic.ConfigOptions[cfg] = configUicOpts;
} }
} }
} }
@@ -1158,17 +1159,17 @@ bool cmQtAutoGenInitializer::SetupCustomTargetsUic()
// Check if the .ui file should be skipped // Check if the .ui file should be skipped
if (sf->GetPropertyAsBool("SKIP_AUTOUIC") || if (sf->GetPropertyAsBool("SKIP_AUTOUIC") ||
sf->GetPropertyAsBool("SKIP_AUTOGEN")) { sf->GetPropertyAsBool("SKIP_AUTOGEN")) {
this->UicSkip.insert(absFile); this->Uic.Skip.insert(absFile);
} }
// Check if the .ui file has uic options // Check if the .ui file has uic options
std::string const uicOpts = sf->GetSafeProperty("AUTOUIC_OPTIONS"); std::string const uicOpts = sf->GetSafeProperty("AUTOUIC_OPTIONS");
if (!uicOpts.empty()) { if (!uicOpts.empty()) {
// Check if file isn't skipped // Check if file isn't skipped
if (this->UicSkip.count(absFile) == 0) { if (this->Uic.Skip.count(absFile) == 0) {
this->UicFileFiles.push_back(absFile); this->Uic.FileFiles.push_back(absFile);
std::vector<std::string> optsVec; std::vector<std::string> optsVec;
cmSystemTools::ExpandListArgument(uicOpts, optsVec); cmSystemTools::ExpandListArgument(uicOpts, optsVec);
this->UicFileOptions.push_back(std::move(optsVec)); this->Uic.FileOptions.push_back(std::move(optsVec));
} }
} }
} }
@@ -1267,7 +1268,7 @@ bool cmQtAutoGenInitializer::GetMocExecutable()
cmLocalGenerator* localGen = this->Target->GetLocalGenerator(); cmLocalGenerator* localGen = this->Target->GetLocalGenerator();
cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse(targetName); cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse(targetName);
if (tgt != nullptr) { if (tgt != nullptr) {
this->MocExecutable = SafeString(tgt->ImportedGetLocation("")); this->Moc.Executable = SafeString(tgt->ImportedGetLocation(""));
} else { } else {
err = "Could not find target " + targetName; err = "Could not find target " + targetName;
} }
@@ -1276,9 +1277,9 @@ bool cmQtAutoGenInitializer::GetMocExecutable()
// Test moc command // Test moc command
if (err.empty()) { if (err.empty()) {
if (cmSystemTools::FileExists(this->MocExecutable, true)) { if (cmSystemTools::FileExists(this->Moc.Executable, true)) {
std::vector<std::string> command; std::vector<std::string> command;
command.push_back(this->MocExecutable); command.push_back(this->Moc.Executable);
command.push_back("-h"); command.push_back("-h");
std::string stdOut; std::string stdOut;
std::string stdErr; std::string stdErr;
@@ -1292,7 +1293,7 @@ bool cmQtAutoGenInitializer::GetMocExecutable()
} }
} else { } else {
err = "The moc executable "; err = "The moc executable ";
err += Quoted(this->MocExecutable); err += Quoted(this->Moc.Executable);
err += " does not exist"; err += " does not exist";
} }
} }
@@ -1328,7 +1329,7 @@ bool cmQtAutoGenInitializer::GetUicExecutable()
cmLocalGenerator* localGen = this->Target->GetLocalGenerator(); cmLocalGenerator* localGen = this->Target->GetLocalGenerator();
cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse(targetName); cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse(targetName);
if (tgt != nullptr) { if (tgt != nullptr) {
this->UicExecutable = SafeString(tgt->ImportedGetLocation("")); this->Uic.Executable = SafeString(tgt->ImportedGetLocation(""));
} else { } else {
if (this->QtVersionMajor == "5") { if (this->QtVersionMajor == "5") {
// Project does not use Qt5Widgets, but has AUTOUIC ON anyway // Project does not use Qt5Widgets, but has AUTOUIC ON anyway
@@ -1341,9 +1342,9 @@ bool cmQtAutoGenInitializer::GetUicExecutable()
// Test uic command // Test uic command
if (err.empty()) { if (err.empty()) {
if (cmSystemTools::FileExists(this->UicExecutable, true)) { if (cmSystemTools::FileExists(this->Uic.Executable, true)) {
std::vector<std::string> command; std::vector<std::string> command;
command.push_back(this->UicExecutable); command.push_back(this->Uic.Executable);
command.push_back("-h"); command.push_back("-h");
std::string stdOut; std::string stdOut;
std::string stdErr; std::string stdErr;
@@ -1357,7 +1358,7 @@ bool cmQtAutoGenInitializer::GetUicExecutable()
} }
} else { } else {
err = "The uic executable "; err = "The uic executable ";
err += Quoted(this->UicExecutable); err += Quoted(this->Uic.Executable);
err += " does not exist"; err += " does not exist";
} }
} }
@@ -1393,7 +1394,7 @@ bool cmQtAutoGenInitializer::GetRccExecutable()
cmLocalGenerator* localGen = this->Target->GetLocalGenerator(); cmLocalGenerator* localGen = this->Target->GetLocalGenerator();
cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse(targetName); cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse(targetName);
if (tgt != nullptr) { if (tgt != nullptr) {
this->RccExecutable = SafeString(tgt->ImportedGetLocation("")); this->Rcc.Executable = SafeString(tgt->ImportedGetLocation(""));
} else { } else {
err = "Could not find target " + targetName; err = "Could not find target " + targetName;
} }
@@ -1402,9 +1403,9 @@ bool cmQtAutoGenInitializer::GetRccExecutable()
// Test rcc command // Test rcc command
if (err.empty()) { if (err.empty()) {
if (cmSystemTools::FileExists(this->RccExecutable, true)) { if (cmSystemTools::FileExists(this->Rcc.Executable, true)) {
std::vector<std::string> command; std::vector<std::string> command;
command.push_back(this->RccExecutable); command.push_back(this->Rcc.Executable);
command.push_back("-h"); command.push_back("-h");
std::string stdOut; std::string stdOut;
std::string stdErr; std::string stdErr;
@@ -1416,9 +1417,9 @@ bool cmQtAutoGenInitializer::GetRccExecutable()
// Detect if rcc supports (-)-list // Detect if rcc supports (-)-list
if (this->QtVersionMajor == "5") { if (this->QtVersionMajor == "5") {
if (stdOut.find("--list") != std::string::npos) { if (stdOut.find("--list") != std::string::npos) {
this->RccListOptions.push_back("--list"); this->Rcc.ListOptions.push_back("--list");
} else { } else {
this->RccListOptions.push_back("-list"); this->Rcc.ListOptions.push_back("-list");
} }
} }
} else { } else {
@@ -1427,7 +1428,7 @@ bool cmQtAutoGenInitializer::GetRccExecutable()
} }
} else { } else {
err = "The rcc executable "; err = "The rcc executable ";
err += Quoted(this->RccExecutable); err += Quoted(this->Rcc.Executable);
err += " does not exist"; err += " does not exist";
} }
} }
@@ -1458,9 +1459,9 @@ bool cmQtAutoGenInitializer::RccListInputs(std::string const& fileName,
error += "\n"; error += "\n";
return false; return false;
} }
if (!RccListOptions.empty()) { if (!this->Rcc.ListOptions.empty()) {
// Use rcc for file listing // Use rcc for file listing
if (RccExecutable.empty()) { if (this->Rcc.Executable.empty()) {
error = "rcc executable not available"; error = "rcc executable not available";
return false; return false;
} }
@@ -1479,8 +1480,9 @@ bool cmQtAutoGenInitializer::RccListInputs(std::string const& fileName,
std::string rccStdErr; std::string rccStdErr;
{ {
std::vector<std::string> cmd; std::vector<std::string> cmd;
cmd.push_back(RccExecutable); cmd.push_back(this->Rcc.Executable);
cmd.insert(cmd.end(), RccListOptions.begin(), RccListOptions.end()); cmd.insert(cmd.end(), this->Rcc.ListOptions.begin(),
this->Rcc.ListOptions.end());
cmd.push_back(fileNameName); cmd.push_back(fileNameName);
result = cmSystemTools::RunSingleCommand( result = cmSystemTools::RunSingleCommand(
cmd, &rccStdOut, &rccStdErr, &retVal, fileDir.c_str(), cmd, &rccStdOut, &rccStdErr, &retVal, fileDir.c_str(),

View File

@@ -72,17 +72,10 @@ private:
private: private:
cmGeneratorTarget* Target; cmGeneratorTarget* Target;
bool MocEnabled;
bool UicEnabled;
bool RccEnabled;
bool MultiConfig; bool MultiConfig;
// Qt // Qt
std::string QtVersionMajor; std::string QtVersionMajor;
std::string QtVersionMinor; std::string QtVersionMinor;
std::string MocExecutable;
std::string UicExecutable;
std::string RccExecutable;
std::vector<std::string> RccListOptions;
// Configurations // Configurations
std::string ConfigDefault; std::string ConfigDefault;
std::vector<std::string> ConfigsList; std::vector<std::string> ConfigsList;
@@ -101,21 +94,37 @@ private:
std::vector<std::string> Headers; std::vector<std::string> Headers;
std::vector<std::string> Sources; std::vector<std::string> Sources;
// Moc // Moc
std::string MocPredefsCmd; struct
std::set<std::string> MocSkip; {
std::string MocIncludes; bool Enabled;
std::map<std::string, std::string> MocIncludesConfig; std::string Executable;
std::string MocDefines; std::string PredefsCmd;
std::map<std::string, std::string> MocDefinesConfig; std::set<std::string> Skip;
std::string Includes;
std::map<std::string, std::string> ConfigIncludes;
std::string Defines;
std::map<std::string, std::string> ConfigDefines;
} Moc;
// Uic // Uic
std::set<std::string> UicSkip; struct
std::vector<std::string> UicSearchPaths; {
std::string UicOptions; bool Enabled;
std::map<std::string, std::string> UicOptionsConfig; std::string Executable;
std::vector<std::string> UicFileFiles; std::set<std::string> Skip;
std::vector<std::vector<std::string>> UicFileOptions; std::vector<std::string> SearchPaths;
std::string Options;
std::map<std::string, std::string> ConfigOptions;
std::vector<std::string> FileFiles;
std::vector<std::vector<std::string>> FileOptions;
} Uic;
// Rcc // Rcc
std::vector<Qrc> Qrcs; struct
{
bool Enabled;
std::string Executable;
std::vector<std::string> ListOptions;
std::vector<Qrc> Qrcs;
} Rcc;
}; };
#endif #endif