cmQtAutoGen.h 3.9 KB

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