1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
5 #include "cmConfigure.h" // IWYU pragma: keep
9 #include <unordered_map>
12 #include <cm/string_view>
14 /** \class cmQtAutoGen
15 * \brief Common base class for QtAutoGen classes
20 /** String value with per configuration variants. */
25 std::unordered_map
<std::string
, std::string
> Config
;
28 /** String values with per configuration variants. */
34 std::unordered_map
<std::string
, C
> Config
;
36 /** Integer version. */
39 unsigned int Major
= 0;
40 unsigned int Minor
= 0;
42 IntegerVersion() = default;
43 IntegerVersion(unsigned int major
, unsigned int 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
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. */
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
,
115 /// @brief Merges newOpts into baseOpts
116 static void RccMergeOptions(std::vector
<std::string
>& baseOpts
,
117 std::vector
<std::string
> const& newOpts
,
121 * @brief Lists files in qrc resource files
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;
155 std::string RccExcutable_
;
156 std::vector
<std::string
> ListOptions_
;