CMake Nightly Date Stamp
[kiteware-cmake.git] / Source / cmQtAutoGen.h
blobb302403bd8f25a0ee473ec41d8c323aad314410b
1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
3 #pragma once
5 #include "cmConfigure.h" // IWYU pragma: keep
7 #include <memory>
8 #include <string>
9 #include <unordered_map>
10 #include <vector>
12 #include <cm/string_view>
14 /** \class cmQtAutoGen
15 * \brief Common base class for QtAutoGen classes
17 class cmQtAutoGen
19 public:
20 /** String value with per configuration variants. */
21 class ConfigString
23 public:
24 std::string Default;
25 std::unordered_map<std::string, std::string> Config;
28 /** String values with per configuration variants. */
29 template <typename C>
30 class ConfigStrings
32 public:
33 C Default;
34 std::unordered_map<std::string, C> Config;
36 /** Integer version. */
37 struct IntegerVersion
39 unsigned int Major = 0;
40 unsigned int Minor = 0;
42 IntegerVersion() = default;
43 IntegerVersion(unsigned int major, unsigned int minor)
44 : Major(major)
45 , Minor(minor)
49 bool operator>(IntegerVersion const version) const
51 return (this->Major > version.Major) ||
52 ((this->Major == version.Major) && (this->Minor > version.Minor));
55 bool operator>=(IntegerVersion const version) const
57 return (this->Major > version.Major) ||
58 ((this->Major == version.Major) && (this->Minor >= version.Minor));
62 /** Compiler features. */
63 class CompilerFeatures
65 public:
66 bool Evaluated = false;
67 std::string HelpOutput;
68 std::vector<std::string> ListOptions;
70 using CompilerFeaturesHandle = std::shared_ptr<CompilerFeatures>;
72 /** AutoGen generator type. */
73 enum class GenT
75 GEN, // AUTOGEN
76 MOC, // AUTOMOC
77 UIC, // AUTOUIC
78 RCC // AUTORCC
81 /// @brief Maximum number of parallel threads/processes in a generator
82 static unsigned int const ParallelMax;
84 /// @brief Returns the generator name
85 static cm::string_view GeneratorName(GenT genType);
86 /// @brief Returns the generator name in upper case
87 static cm::string_view GeneratorNameUpper(GenT genType);
89 /// @brief Returns a string with the requested tool names
90 static std::string Tools(bool moc, bool uic, bool rcc);
92 /// @brief Returns the string escaped and enclosed in quotes
93 static std::string Quoted(cm::string_view text);
95 static std::string QuotedCommand(std::vector<std::string> const& command);
97 /// @brief Returns the file name without path and extension (thread safe)
98 static std::string FileNameWithoutLastExtension(cm::string_view filename);
100 /// @brief Returns the parent directory of the file (thread safe)
101 static std::string ParentDir(cm::string_view filename);
103 /// @brief Returns the parent directory of the file with a "/" suffix
104 static std::string SubDirPrefix(cm::string_view filename);
106 /// @brief Appends the suffix to the filename before the last dot
107 static std::string AppendFilenameSuffix(cm::string_view filename,
108 cm::string_view suffix);
110 /// @brief Merges newOpts into baseOpts
111 static void UicMergeOptions(std::vector<std::string>& baseOpts,
112 std::vector<std::string> const& newOpts,
113 bool isQt5OrLater);
115 /// @brief Merges newOpts into baseOpts
116 static void RccMergeOptions(std::vector<std::string>& baseOpts,
117 std::vector<std::string> const& newOpts,
118 bool isQt5OrLater);
120 /** @class RccLister
121 * @brief Lists files in qrc resource files
123 class RccLister
125 public:
126 RccLister();
127 RccLister(std::string rccExecutable, std::vector<std::string> listOptions);
129 //! The rcc executable
130 std::string const& RccExcutable() const { return this->RccExcutable_; }
131 void SetRccExecutable(std::string const& rccExecutable)
133 this->RccExcutable_ = rccExecutable;
136 //! The rcc executable list options
137 std::vector<std::string> const& ListOptions() const
139 return this->ListOptions_;
141 void SetListOptions(std::vector<std::string> const& listOptions)
143 this->ListOptions_ = listOptions;
147 * @brief Lists a files in the qrcFile
148 * @arg files The file names are appended to this list
149 * @arg error contains the error message when the function fails
151 bool list(std::string const& qrcFile, std::vector<std::string>& files,
152 std::string& error, bool verbose = false) const;
154 private:
155 std::string RccExcutable_;
156 std::vector<std::string> ListOptions_;