cmQtAutoGen.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 <string>
  7. #include <vector>
  8. /** \class cmQtAutoGen
  9. * \brief Common base class for QtAutoGen classes
  10. */
  11. class cmQtAutoGen
  12. {
  13. public:
  14. /// @brief Nested lists separator
  15. static std::string const ListSep;
  16. /// @brief Maximum number of parallel threads/processes in a generator
  17. static unsigned int const ParallelMax;
  18. /// @brief AutoGen generator type
  19. enum class GeneratorT
  20. {
  21. GEN, // General
  22. MOC,
  23. UIC,
  24. RCC
  25. };
  26. /// @brief Integer version
  27. struct IntegerVersion
  28. {
  29. unsigned int Major = 0;
  30. unsigned int Minor = 0;
  31. IntegerVersion() = default;
  32. IntegerVersion(unsigned int major, unsigned int minor)
  33. : Major(major)
  34. , Minor(minor)
  35. {
  36. }
  37. bool operator>(IntegerVersion const version)
  38. {
  39. return (this->Major > version.Major) ||
  40. ((this->Major == version.Major) && (this->Minor > version.Minor));
  41. }
  42. bool operator>=(IntegerVersion const version)
  43. {
  44. return (this->Major > version.Major) ||
  45. ((this->Major == version.Major) && (this->Minor >= version.Minor));
  46. }
  47. };
  48. public:
  49. /// @brief Returns the generator name
  50. static std::string const& GeneratorName(GeneratorT genType);
  51. /// @brief Returns the generator name in upper case
  52. static std::string GeneratorNameUpper(GeneratorT genType);
  53. /// @brief Returns a string with the requested tool names
  54. static std::string Tools(bool moc, bool uic, bool rcc);
  55. /// @brief Returns the string escaped and enclosed in quotes
  56. static std::string Quoted(std::string const& text);
  57. static std::string QuotedCommand(std::vector<std::string> const& command);
  58. /// @brief Returns the parent directory of the file with a "/" suffix
  59. static std::string SubDirPrefix(std::string const& filename);
  60. /// @brief Appends the suffix to the filename before the last dot
  61. static std::string AppendFilenameSuffix(std::string const& filename,
  62. std::string const& suffix);
  63. /// @brief Merges newOpts into baseOpts
  64. static void UicMergeOptions(std::vector<std::string>& baseOpts,
  65. std::vector<std::string> const& newOpts,
  66. bool isQt5);
  67. /// @brief Merges newOpts into baseOpts
  68. static void RccMergeOptions(std::vector<std::string>& baseOpts,
  69. std::vector<std::string> const& newOpts,
  70. bool isQt5);
  71. /// @brief Parses the content of a qrc file
  72. ///
  73. /// Use when rcc does not support the "--list" option
  74. static void RccListParseContent(std::string const& content,
  75. std::vector<std::string>& files);
  76. /// @brief Parses the output of the "rcc --list ..." command
  77. static bool RccListParseOutput(std::string const& rccStdOut,
  78. std::string const& rccStdErr,
  79. std::vector<std::string>& files,
  80. std::string& error);
  81. /// @brief Converts relative qrc entry paths to full paths
  82. static void RccListConvertFullPath(std::string const& qrcFileDir,
  83. std::vector<std::string>& files);
  84. };
  85. #endif