cmQtAutoGen.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmQtAutoGen_h
  4. #define cmQtAutoGen_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include <memory>
  7. #include <string>
  8. #include <vector>
  9. /** \class cmQtAutoGen
  10. * \brief Common base class for QtAutoGen classes
  11. */
  12. class cmQtAutoGen
  13. {
  14. public:
  15. /// @brief Integer version
  16. struct IntegerVersion
  17. {
  18. unsigned int Major = 0;
  19. unsigned int Minor = 0;
  20. IntegerVersion() = default;
  21. IntegerVersion(unsigned int major, unsigned int minor)
  22. : Major(major)
  23. , Minor(minor)
  24. {
  25. }
  26. bool operator>(IntegerVersion const version)
  27. {
  28. return (this->Major > version.Major) ||
  29. ((this->Major == version.Major) && (this->Minor > version.Minor));
  30. }
  31. bool operator>=(IntegerVersion const version)
  32. {
  33. return (this->Major > version.Major) ||
  34. ((this->Major == version.Major) && (this->Minor >= version.Minor));
  35. }
  36. };
  37. class CompilerFeatures
  38. {
  39. public:
  40. bool Evaluated = false;
  41. std::string HelpOutput;
  42. std::vector<std::string> ListOptions;
  43. };
  44. typedef std::shared_ptr<CompilerFeatures> CompilerFeaturesHandle;
  45. /// @brief AutoGen generator type
  46. enum class GenT
  47. {
  48. GEN, // AUTOGEN
  49. MOC, // AUTOMOC
  50. UIC, // AUTOUIC
  51. RCC // AUTORCC
  52. };
  53. /// @brief Nested lists separator
  54. static std::string const ListSep;
  55. /// @brief Maximum number of parallel threads/processes in a generator
  56. static unsigned int const ParallelMax;
  57. public:
  58. /// @brief Returns the generator name
  59. static std::string const& GeneratorName(GenT genType);
  60. /// @brief Returns the generator name in upper case
  61. static std::string const& GeneratorNameUpper(GenT genType);
  62. /// @brief Returns a string with the requested tool names
  63. static std::string Tools(bool moc, bool uic, bool rcc);
  64. /// @brief Returns the string escaped and enclosed in quotes
  65. static std::string Quoted(std::string const& text);
  66. static std::string QuotedCommand(std::vector<std::string> const& command);
  67. /// @brief Returns the parent directory of the file with a "/" suffix
  68. static std::string SubDirPrefix(std::string const& filename);
  69. /// @brief Appends the suffix to the filename before the last dot
  70. static std::string AppendFilenameSuffix(std::string const& filename,
  71. std::string const& suffix);
  72. /// @brief Merges newOpts into baseOpts
  73. static void UicMergeOptions(std::vector<std::string>& baseOpts,
  74. std::vector<std::string> const& newOpts,
  75. bool isQt5);
  76. /// @brief Merges newOpts into baseOpts
  77. static void RccMergeOptions(std::vector<std::string>& baseOpts,
  78. std::vector<std::string> const& newOpts,
  79. bool isQt5);
  80. /** @class RccLister
  81. * @brief Lists files in qrc resource files
  82. */
  83. class RccLister
  84. {
  85. public:
  86. RccLister();
  87. RccLister(std::string rccExecutable, std::vector<std::string> listOptions);
  88. //! The rcc executable
  89. std::string const& RccExcutable() const { return RccExcutable_; }
  90. void SetRccExecutable(std::string const& rccExecutable)
  91. {
  92. RccExcutable_ = rccExecutable;
  93. }
  94. //! The rcc executable list options
  95. std::vector<std::string> const& ListOptions() const
  96. {
  97. return ListOptions_;
  98. }
  99. void SetListOptions(std::vector<std::string> const& listOptions)
  100. {
  101. ListOptions_ = listOptions;
  102. }
  103. /**
  104. * @brief Lists a files in the qrcFile
  105. * @arg files The file names are appended to this list
  106. * @arg error contains the error message when the function fails
  107. */
  108. bool list(std::string const& qrcFile, std::vector<std::string>& files,
  109. std::string& error, bool verbose = false) const;
  110. private:
  111. std::string RccExcutable_;
  112. std::vector<std::string> ListOptions_;
  113. };
  114. };
  115. #endif