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