diff options
author | Brad King <brad.king@kitware.com> | 2019-04-04 15:29:22 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-04-04 15:29:51 (GMT) |
commit | dc6b76d1e751224c60aba5489fb62228cd8a6bad (patch) | |
tree | 5704642cc25414b10ed43011dd06b626b09307dd | |
parent | d1c2f8787ceb0cb5e30d433e05f774bbdd910ef9 (diff) | |
parent | 18f7b2ed2111ff9dac5ef83d8bbf20b826b8bbe9 (diff) | |
download | CMake-dc6b76d1e751224c60aba5489fb62228cd8a6bad.zip CMake-dc6b76d1e751224c60aba5489fb62228cd8a6bad.tar.gz CMake-dc6b76d1e751224c60aba5489fb62228cd8a6bad.tar.bz2 |
Merge topic 'autogen_keywords_class'
18f7b2ed21 Autogen: Add more frequently used keywords to Keywords class
5fb122ff75 Autogen: Add `AUTO*_EXECUTABLE` strings to Keywords class
b32e18fb88 Autogen: Remove static const generator name strings from cmQtAutoGen
5431395d68 Autogen: Add cmQtAutogenGlobalInitializer::Keywords class
78eccc7836 Autogen: Remove lowercase generator name from generator variables class
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3182
-rw-r--r-- | Source/cmQtAutoGen.cxx | 46 | ||||
-rw-r--r-- | Source/cmQtAutoGen.h | 9 | ||||
-rw-r--r-- | Source/cmQtAutoGenGlobalInitializer.cxx | 30 | ||||
-rw-r--r-- | Source/cmQtAutoGenGlobalInitializer.h | 30 | ||||
-rw-r--r-- | Source/cmQtAutoGenInitializer.cxx | 43 | ||||
-rw-r--r-- | Source/cmQtAutoGenInitializer.h | 16 |
6 files changed, 99 insertions, 75 deletions
diff --git a/Source/cmQtAutoGen.cxx b/Source/cmQtAutoGen.cxx index 87ef112..d71d82f 100644 --- a/Source/cmQtAutoGen.cxx +++ b/Source/cmQtAutoGen.cxx @@ -73,44 +73,44 @@ void MergeOptions(std::vector<std::string>& baseOpts, unsigned int const cmQtAutoGen::ParallelMax = 64; std::string const cmQtAutoGen::ListSep = "<<<S>>>"; -std::string const cmQtAutoGen::GenAutoGen = "AutoGen"; -std::string const cmQtAutoGen::GenAutoMoc = "AutoMoc"; -std::string const cmQtAutoGen::GenAutoUic = "AutoUic"; -std::string const cmQtAutoGen::GenAutoRcc = "AutoRcc"; - -std::string const cmQtAutoGen::GenAUTOGEN = "AUTOGEN"; -std::string const cmQtAutoGen::GenAUTOMOC = "AUTOMOC"; -std::string const cmQtAutoGen::GenAUTOUIC = "AUTOUIC"; -std::string const cmQtAutoGen::GenAUTORCC = "AUTORCC"; - std::string const& cmQtAutoGen::GeneratorName(GenT genType) { + static const std::string AutoGen("AutoGen"); + static const std::string AutoMoc("AutoMoc"); + static const std::string AutoUic("AutoUic"); + static const std::string AutoRcc("AutoRcc"); + switch (genType) { case GenT::GEN: - return GenAutoGen; + return AutoGen; case GenT::MOC: - return GenAutoMoc; + return AutoMoc; case GenT::UIC: - return GenAutoUic; + return AutoUic; case GenT::RCC: - return GenAutoRcc; + return AutoRcc; } - return GenAutoGen; + return AutoGen; } std::string const& cmQtAutoGen::GeneratorNameUpper(GenT genType) { + static const std::string AUTOGEN("AUTOGEN"); + static const std::string AUTOMOC("AUTOMOC"); + static const std::string AUTOUIC("AUTOUIC"); + static const std::string AUTORCC("AUTORCC"); + switch (genType) { case GenT::GEN: - return GenAUTOGEN; + return AUTOGEN; case GenT::MOC: - return GenAUTOMOC; + return AUTOMOC; case GenT::UIC: - return GenAUTOUIC; + return AUTOUIC; case GenT::RCC: - return GenAUTORCC; + return AUTORCC; } - return GenAUTOGEN; + return AUTOGEN; } std::string cmQtAutoGen::Tools(bool moc, bool uic, bool rcc) @@ -118,13 +118,13 @@ std::string cmQtAutoGen::Tools(bool moc, bool uic, bool rcc) std::string res; std::vector<std::string> lst; if (moc) { - lst.emplace_back(GenAUTOMOC); + lst.emplace_back("AUTOMOC"); } if (uic) { - lst.emplace_back(GenAUTOUIC); + lst.emplace_back("AUTOUIC"); } if (rcc) { - lst.emplace_back(GenAUTORCC); + lst.emplace_back("AUTORCC"); } switch (lst.size()) { case 1: diff --git a/Source/cmQtAutoGen.h b/Source/cmQtAutoGen.h index 6cc8df1..d127a71 100644 --- a/Source/cmQtAutoGen.h +++ b/Source/cmQtAutoGen.h @@ -51,15 +51,6 @@ public: /// @brief Nested lists separator static std::string const ListSep; - // Generator names - static std::string const GenAutoGen; - static std::string const GenAutoMoc; - static std::string const GenAutoUic; - static std::string const GenAutoRcc; - static std::string const GenAUTOGEN; - static std::string const GenAUTOMOC; - static std::string const GenAUTOUIC; - static std::string const GenAUTORCC; /// @brief Maximum number of parallel threads/processes in a generator static unsigned int const ParallelMax; diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx index 7bd0e52..59e17d7 100644 --- a/Source/cmQtAutoGenGlobalInitializer.cxx +++ b/Source/cmQtAutoGenGlobalInitializer.cxx @@ -20,6 +20,24 @@ #include <memory> #include <utility> +cmQtAutoGenGlobalInitializer::Keywords::Keywords() + : AUTOMOC("AUTOMOC") + , AUTOUIC("AUTOUIC") + , AUTORCC("AUTORCC") + , AUTOMOC_EXECUTABLE("AUTOMOC_EXECUTABLE") + , AUTOUIC_EXECUTABLE("AUTOUIC_EXECUTABLE") + , AUTORCC_EXECUTABLE("AUTORCC_EXECUTABLE") + , SKIP_AUTOGEN("SKIP_AUTOGEN") + , SKIP_AUTOMOC("SKIP_AUTOMOC") + , SKIP_AUTOUIC("SKIP_AUTOUIC") + , SKIP_AUTORCC("SKIP_AUTORCC") + , AUTOUIC_OPTIONS("AUTOUIC_OPTIONS") + , AUTORCC_OPTIONS("AUTORCC_OPTIONS") + , qrc("qrc") + , ui("ui") +{ +} + cmQtAutoGenGlobalInitializer::cmQtAutoGenGlobalInitializer( std::vector<cmLocalGenerator*> const& localGenerators) { @@ -74,16 +92,16 @@ cmQtAutoGenGlobalInitializer::cmQtAutoGenGlobalInitializer( continue; } - bool const moc = target->GetPropertyAsBool(cmQtAutoGen::GenAUTOMOC); - bool const uic = target->GetPropertyAsBool(cmQtAutoGen::GenAUTOUIC); - bool const rcc = target->GetPropertyAsBool(cmQtAutoGen::GenAUTORCC); + bool const moc = target->GetPropertyAsBool(kw().AUTOMOC); + bool const uic = target->GetPropertyAsBool(kw().AUTOUIC); + bool const rcc = target->GetPropertyAsBool(kw().AUTORCC); if (moc || uic || rcc) { std::string const mocExec = - target->GetSafeProperty("AUTOMOC_EXECUTABLE"); + target->GetSafeProperty(kw().AUTOMOC_EXECUTABLE); std::string const uicExec = - target->GetSafeProperty("AUTOUIC_EXECUTABLE"); + target->GetSafeProperty(kw().AUTOUIC_EXECUTABLE); std::string const rccExec = - target->GetSafeProperty("AUTORCC_EXECUTABLE"); + target->GetSafeProperty(kw().AUTORCC_EXECUTABLE); // We support Qt4, Qt5 and Qt6 auto qtVersion = cmQtAutoGenInitializer::GetQtVersion(target); diff --git a/Source/cmQtAutoGenGlobalInitializer.h b/Source/cmQtAutoGenGlobalInitializer.h index 74184a0..77429b7 100644 --- a/Source/cmQtAutoGenGlobalInitializer.h +++ b/Source/cmQtAutoGenGlobalInitializer.h @@ -18,10 +18,39 @@ class cmQtAutoGenInitializer; class cmQtAutoGenGlobalInitializer { public: + /// @brief Collection of QtAutogen related keywords + class Keywords + { + public: + Keywords(); + + std::string AUTOMOC; + std::string AUTOUIC; + std::string AUTORCC; + + std::string AUTOMOC_EXECUTABLE; + std::string AUTOUIC_EXECUTABLE; + std::string AUTORCC_EXECUTABLE; + + std::string SKIP_AUTOGEN; + std::string SKIP_AUTOMOC; + std::string SKIP_AUTOUIC; + std::string SKIP_AUTORCC; + + std::string AUTOUIC_OPTIONS; + std::string AUTORCC_OPTIONS; + + std::string qrc; + std::string ui; + }; + +public: cmQtAutoGenGlobalInitializer( std::vector<cmLocalGenerator*> const& localGenerators); ~cmQtAutoGenGlobalInitializer(); + Keywords const& kw() const { return Keywords_; }; + bool generate(); private: @@ -48,6 +77,7 @@ private: std::map<cmLocalGenerator*, std::string> GlobalAutoGenTargets_; std::map<cmLocalGenerator*, std::string> GlobalAutoRccTargets_; std::unordered_map<std::string, std::string> ExecutableTestOutputs_; + Keywords const Keywords_; }; #endif diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index ef8fe73..d80aaa2 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -606,28 +606,19 @@ bool cmQtAutoGenInitializer::InitRcc() bool cmQtAutoGenInitializer::InitScanFiles() { cmMakefile* makefile = this->Target->Target->GetMakefile(); + auto const& kw = this->GlobalInitializer->kw(); - // String constants - std::string const SKIP_AUTOGEN_str = "SKIP_AUTOGEN"; - std::string const SKIP_AUTOMOC_str = "SKIP_AUTOMOC"; - std::string const SKIP_AUTOUIC_str = "SKIP_AUTOUIC"; - std::string const SKIP_AUTORCC_str = "SKIP_AUTORCC"; - std::string const AUTOUIC_OPTIONS_str = "AUTOUIC_OPTIONS"; - std::string const AUTORCC_OPTIONS_str = "AUTORCC_OPTIONS"; - std::string const qrc_str = "qrc"; - std::string const ui_str = "ui"; - - auto makeMUFile = [&](cmSourceFile* sf, std::string const& fullPath, - bool muIt) -> MUFileHandle { + auto makeMUFile = [this, &kw](cmSourceFile* sf, std::string const& fullPath, + bool muIt) -> MUFileHandle { MUFileHandle muf = cm::make_unique<MUFile>(); muf->RealPath = cmSystemTools::GetRealPath(fullPath); muf->SF = sf; muf->Generated = sf->GetIsGenerated(); - bool const skipAutogen = sf->GetPropertyAsBool(SKIP_AUTOGEN_str); + bool const skipAutogen = sf->GetPropertyAsBool(kw.SKIP_AUTOGEN); muf->SkipMoc = this->Moc.Enabled && - (skipAutogen || sf->GetPropertyAsBool(SKIP_AUTOMOC_str)); + (skipAutogen || sf->GetPropertyAsBool(kw.SKIP_AUTOMOC)); muf->SkipUic = this->Uic.Enabled && - (skipAutogen || sf->GetPropertyAsBool(SKIP_AUTOUIC_str)); + (skipAutogen || sf->GetPropertyAsBool(kw.SKIP_AUTOUIC)); if (muIt) { muf->MocIt = this->Moc.Enabled && !muf->SkipMoc; muf->UicIt = this->Uic.Enabled && !muf->SkipUic; @@ -678,8 +669,8 @@ bool cmQtAutoGenInitializer::InitScanFiles() // Register rcc enabled files if (this->Rcc.Enabled) { - if ((ext == qrc_str) && !sf->GetPropertyAsBool(SKIP_AUTOGEN_str) && - !sf->GetPropertyAsBool(SKIP_AUTORCC_str)) { + if ((ext == kw.qrc) && !sf->GetPropertyAsBool(kw.SKIP_AUTOGEN) && + !sf->GetPropertyAsBool(kw.SKIP_AUTORCC)) { // Register qrc file Qrc qrc; qrc.QrcFile = cmSystemTools::GetRealPath(fullPath); @@ -688,7 +679,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() qrc.Generated = sf->GetIsGenerated(); // RCC options { - std::string const opts = sf->GetSafeProperty(AUTORCC_OPTIONS_str); + std::string const opts = sf->GetSafeProperty(kw.AUTORCC_OPTIONS); if (!opts.empty()) { cmSystemTools::ExpandListArgument(opts, qrc.Options); } @@ -798,15 +789,15 @@ bool cmQtAutoGenInitializer::InitScanFiles() this->AutogenTarget.Sources.emplace(sf, std::move(muf)); } } - } else if (this->Uic.Enabled && (ext == ui_str)) { + } else if (this->Uic.Enabled && (ext == kw.ui)) { // .ui file std::string realPath = cmSystemTools::GetRealPath(fullPath); - bool const skipAutogen = sf->GetPropertyAsBool(SKIP_AUTOGEN_str); + bool const skipAutogen = sf->GetPropertyAsBool(kw.SKIP_AUTOGEN); bool const skipUic = - (skipAutogen || sf->GetPropertyAsBool(SKIP_AUTOUIC_str)); + (skipAutogen || sf->GetPropertyAsBool(kw.SKIP_AUTOUIC)); if (!skipUic) { // Check if the .ui file has uic options - std::string const uicOpts = sf->GetSafeProperty(AUTOUIC_OPTIONS_str); + std::string const uicOpts = sf->GetSafeProperty(kw.AUTOUIC_OPTIONS); if (!uicOpts.empty()) { this->Uic.FileFiles.push_back(std::move(realPath)); std::vector<std::string> optsVec; @@ -834,11 +825,11 @@ bool cmQtAutoGenInitializer::InitScanFiles() msg += '\n'; std::string property; if (this->Moc.Enabled && this->Uic.Enabled) { - property = "SKIP_AUTOGEN"; + property = kw.SKIP_AUTOGEN; } else if (this->Moc.Enabled) { - property = "SKIP_AUTOMOC"; + property = kw.SKIP_AUTOMOC; } else if (this->Uic.Enabled) { - property = "SKIP_AUTOUIC"; + property = kw.SKIP_AUTOUIC; } msg += "For compatibility, CMake is excluding the GENERATED source " "file(s):\n"; @@ -866,7 +857,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() // Target rcc options std::vector<std::string> optionsTarget; cmSystemTools::ExpandListArgument( - this->Target->GetSafeProperty("AUTORCC_OPTIONS"), optionsTarget); + this->Target->GetSafeProperty(kw.AUTORCC_OPTIONS), optionsTarget); // Check if file name is unique for (Qrc& qrc : this->Rcc.Qrcs) { diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h index 1f4087f..e7e5db2 100644 --- a/Source/cmQtAutoGenInitializer.h +++ b/Source/cmQtAutoGenInitializer.h @@ -62,7 +62,6 @@ public: bool Enabled = false; // Generator type/name GenT Gen; - std::string const& GenName; std::string const& GenNameUpper; // Executable std::string ExecutableTargetName; @@ -71,11 +70,9 @@ public: bool ExecutableExists = false; /// @brief Constructor - GenVarsT(GenT gen, std::string const& genName, - std::string const& genNameUpper) + GenVarsT(GenT gen) : Gen(gen) - , GenName(genName) - , GenNameUpper(genNameUpper){}; + , GenNameUpper(cmQtAutoGen::GeneratorNameUpper(gen)){}; }; /// @brief Writes a CMake info file @@ -213,8 +210,7 @@ private: /// @brief Constructor MocT() - : GenVarsT(cmQtAutoGen::GenT::MOC, cmQtAutoGen::GenAutoMoc, - cmQtAutoGen::GenAUTOMOC){}; + : GenVarsT(GenT::MOC){}; } Moc; /// @brief Uic only variables @@ -229,8 +225,7 @@ private: /// @brief Constructor UicT() - : GenVarsT(cmQtAutoGen::GenT::UIC, cmQtAutoGen::GenAutoUic, - cmQtAutoGen::GenAUTOUIC){}; + : GenVarsT(GenT::UIC){}; } Uic; /// @brief Rcc only variables @@ -242,8 +237,7 @@ private: /// @brief Constructor RccT() - : GenVarsT(cmQtAutoGen::GenT::RCC, cmQtAutoGen::GenAutoRcc, - cmQtAutoGen::GenAUTORCC){}; + : GenVarsT(GenT::RCC){}; } Rcc; }; |