1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-16 05:26:58 +08:00

Autogen: Add and use QtAutoGen::Tools method

This commit is contained in:
Sebastian Holtermann
2019-01-14 17:33:03 +01:00
parent b2343ff086
commit f2f1661334
4 changed files with 40 additions and 14 deletions

View File

@@ -99,6 +99,41 @@ std::string cmQtAutoGen::GeneratorNameUpper(GeneratorT genType)
return cmSystemTools::UpperCase(cmQtAutoGen::GeneratorName(genType));
}
std::string cmQtAutoGen::Tools(bool moc, bool uic, bool rcc)
{
std::string res;
std::vector<std::string> lst;
if (moc) {
lst.emplace_back("AUTOMOC");
}
if (uic) {
lst.emplace_back("AUTOUIC");
}
if (rcc) {
lst.emplace_back("AUTORCC");
}
switch (lst.size()) {
case 1:
res += lst.at(0);
break;
case 2:
res += lst.at(0);
res += " and ";
res += lst.at(1);
break;
case 3:
res += lst.at(0);
res += ", ";
res += lst.at(1);
res += " and ";
res += lst.at(2);
break;
default:
break;
}
return res;
}
std::string cmQtAutoGen::Quoted(std::string const& text)
{
static const char* rep[18] = { "\\", "\\\\", "\"", "\\\"", "\a", "\\a",

View File

@@ -60,6 +60,9 @@ public:
/// @brief Returns the generator name in upper case
static std::string GeneratorNameUpper(GeneratorT genType);
/// @brief Returns a string with the requested tool names
static std::string Tools(bool moc, bool uic, bool rcc);
/// @brief Returns the string escaped and enclosed in quotes
static std::string Quoted(std::string const& text);

View File

@@ -102,19 +102,7 @@ cmQtAutoGenGlobalInitializer::cmQtAutoGenGlobalInitializer(
std::string msg = "AUTOGEN: No valid Qt version found for target ";
msg += target->GetName();
msg += ". ";
{
std::vector<std::string> lst;
if (mocDisabled) {
lst.emplace_back("AUTOMOC");
}
if (uicDisabled) {
lst.emplace_back("AUTOUIC");
}
if (rccDisabled) {
lst.emplace_back("AUTORCC");
}
msg += cmJoin(lst, ", ");
}
msg += cmQtAutoGen::Tools(mocDisabled, uicDisabled, rccDisabled);
msg += " disabled. Consider adding:\n";
if (uicDisabled) {
msg += " find_package(Qt5 COMPONENTS Widgets)\n";

View File

@@ -1,5 +1,5 @@
^CMake Warning \(dev\) in CMakeLists.txt:
AUTOGEN: No valid Qt version found for target main. AUTOMOC, AUTOUIC,
AUTOGEN: No valid Qt version found for target main. AUTOMOC, AUTOUIC and
AUTORCC disabled. Consider adding:
find_package\(Qt5 COMPONENTS Widgets\)