cmQtAutoGenInitializer.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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 cmQtAutoGenInitializer_h
  4. #define cmQtAutoGenInitializer_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include "cmGeneratedFileStream.h"
  7. #include "cmQtAutoGen.h"
  8. #include <map>
  9. #include <ostream>
  10. #include <set>
  11. #include <string>
  12. #include <vector>
  13. class cmGeneratorTarget;
  14. class cmTarget;
  15. class cmQtAutoGenGlobalInitializer;
  16. /// @brief Initializes the QtAutoGen generators
  17. class cmQtAutoGenInitializer : public cmQtAutoGen
  18. {
  19. public:
  20. /// @brief Rcc job information
  21. class Qrc
  22. {
  23. public:
  24. Qrc() {}
  25. public:
  26. std::string LockFile;
  27. std::string QrcFile;
  28. std::string QrcName;
  29. std::string PathChecksum;
  30. std::string InfoFile;
  31. std::string SettingsFile;
  32. std::map<std::string, std::string> ConfigSettingsFile;
  33. std::string RccFile;
  34. bool Generated = false;
  35. bool Unique = false;
  36. std::vector<std::string> Options;
  37. std::vector<std::string> Resources;
  38. };
  39. /// @brief Writes a CMake info file
  40. class InfoWriter
  41. {
  42. public:
  43. /// @brief Open the given file
  44. InfoWriter(std::string const& filename);
  45. /// @return True if the file is open
  46. explicit operator bool() const { return static_cast<bool>(Ofs_); }
  47. void Write(const char* text) { Ofs_ << text; }
  48. void Write(const char* key, std::string const& value);
  49. void WriteUInt(const char* key, unsigned int value);
  50. template <class C>
  51. void WriteStrings(const char* key, C const& container);
  52. void WriteConfig(const char* key,
  53. std::map<std::string, std::string> const& map);
  54. template <class C>
  55. void WriteConfigStrings(const char* key,
  56. std::map<std::string, C> const& map);
  57. void WriteNestedLists(const char* key,
  58. std::vector<std::vector<std::string>> const& lists);
  59. private:
  60. template <class IT>
  61. static std::string ListJoin(IT it_begin, IT it_end);
  62. static std::string ConfigKey(const char* key, std::string const& config);
  63. private:
  64. cmGeneratedFileStream Ofs_;
  65. };
  66. public:
  67. static IntegerVersion GetQtVersion(cmGeneratorTarget const* target);
  68. cmQtAutoGenInitializer(cmQtAutoGenGlobalInitializer* globalInitializer,
  69. cmGeneratorTarget* target,
  70. IntegerVersion const& qtVersion, bool mocEnabled,
  71. bool uicEnabled, bool rccEnabled,
  72. bool globalAutogenTarget, bool globalAutoRccTarget);
  73. bool InitCustomTargets();
  74. bool SetupCustomTargets();
  75. private:
  76. bool InitMoc();
  77. bool InitUic();
  78. bool InitRcc();
  79. bool InitScanFiles();
  80. bool InitAutogenTarget();
  81. bool InitRccTargets();
  82. bool SetupWriteAutogenInfo();
  83. bool SetupWriteRccInfo();
  84. void AddGeneratedSource(std::string const& filename, GeneratorT genType);
  85. bool GetMocExecutable();
  86. bool GetUicExecutable();
  87. bool GetRccExecutable();
  88. bool RccListInputs(std::string const& fileName,
  89. std::vector<std::string>& files,
  90. std::string& errorMessage);
  91. private:
  92. cmQtAutoGenGlobalInitializer* GlobalInitializer;
  93. cmGeneratorTarget* Target;
  94. // Configuration
  95. IntegerVersion QtVersion;
  96. bool MultiConfig = false;
  97. std::string ConfigDefault;
  98. std::vector<std::string> ConfigsList;
  99. std::string Verbosity;
  100. std::string TargetsFolder;
  101. /// @brief Common directories
  102. struct
  103. {
  104. std::string Info;
  105. std::string Build;
  106. std::string Work;
  107. std::string Include;
  108. std::map<std::string, std::string> ConfigInclude;
  109. } Dir;
  110. /// @brief Autogen target variables
  111. struct
  112. {
  113. std::string Name;
  114. bool GlobalTarget = false;
  115. // Settings
  116. std::string Parallel;
  117. // Configuration files
  118. std::string InfoFile;
  119. std::string SettingsFile;
  120. std::map<std::string, std::string> ConfigSettingsFile;
  121. // Dependencies
  122. bool DependOrigin = false;
  123. std::set<std::string> DependFiles;
  124. std::set<cmTarget*> DependTargets;
  125. // Sources to process
  126. std::vector<std::string> Headers;
  127. std::vector<std::string> Sources;
  128. std::vector<std::string> HeadersGenerated;
  129. std::vector<std::string> SourcesGenerated;
  130. } AutogenTarget;
  131. /// @brief Moc only variables
  132. struct
  133. {
  134. bool Enabled = false;
  135. std::string Executable;
  136. std::string PredefsCmd;
  137. std::set<std::string> Skip;
  138. std::vector<std::string> Includes;
  139. std::map<std::string, std::vector<std::string>> ConfigIncludes;
  140. std::set<std::string> Defines;
  141. std::map<std::string, std::set<std::string>> ConfigDefines;
  142. std::string MocsCompilation;
  143. } Moc;
  144. ///@brief Uic only variables
  145. struct
  146. {
  147. bool Enabled = false;
  148. std::string Executable;
  149. std::set<std::string> Skip;
  150. std::vector<std::string> SearchPaths;
  151. std::vector<std::string> Options;
  152. std::map<std::string, std::vector<std::string>> ConfigOptions;
  153. std::vector<std::string> FileFiles;
  154. std::vector<std::vector<std::string>> FileOptions;
  155. } Uic;
  156. /// @brief Rcc only variables
  157. struct
  158. {
  159. bool Enabled = false;
  160. bool GlobalTarget = false;
  161. std::string Executable;
  162. std::vector<std::string> ListOptions;
  163. std::vector<Qrc> Qrcs;
  164. } Rcc;
  165. };
  166. #endif