summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-01-16 14:51:26 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-01-16 14:51:33 (GMT)
commite44cc45530b002546bae11a34e77a3a730fd14e4 (patch)
tree4c085af51563cde788a63e4c2311e15242729299
parenta8b447d72e13b3356893737adba0a46ea065f70d (diff)
parent5fe18eee1392c312612fad0e6f408ea7cb1ef29d (diff)
downloadCMake-e44cc45530b002546bae11a34e77a3a730fd14e4.zip
CMake-e44cc45530b002546bae11a34e77a3a730fd14e4.tar.gz
CMake-e44cc45530b002546bae11a34e77a3a730fd14e4.tar.bz2
Merge topic 'autogen_adaptive_warning'
5fe18eee13 Autogen: Adaptive missing Qt warning f2f1661334 Autogen: Add and use QtAutoGen::Tools method b2343ff086 Autogen: Fix rcc validity check Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2806
-rw-r--r--Source/cmQtAutoGen.cxx35
-rw-r--r--Source/cmQtAutoGen.h3
-rw-r--r--Source/cmQtAutoGenGlobalInitializer.cxx36
-rw-r--r--Source/cmQtAutoGenInitializer.cxx43
-rw-r--r--Source/cmQtAutoGenInitializer.h5
-rw-r--r--Tests/RunCMake/Autogen/NoQt-stderr.txt4
6 files changed, 80 insertions, 46 deletions
diff --git a/Source/cmQtAutoGen.cxx b/Source/cmQtAutoGen.cxx
index 2786646..653caf7 100644
--- a/Source/cmQtAutoGen.cxx
+++ b/Source/cmQtAutoGen.cxx
@@ -100,6 +100,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",
diff --git a/Source/cmQtAutoGen.h b/Source/cmQtAutoGen.h
index 4118dc7..96d1946 100644
--- a/Source/cmQtAutoGen.h
+++ b/Source/cmQtAutoGen.h
@@ -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);
diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx
index cdd96ce..431c5bc 100644
--- a/Source/cmQtAutoGenGlobalInitializer.cxx
+++ b/Source/cmQtAutoGenGlobalInitializer.cxx
@@ -85,15 +85,15 @@ cmQtAutoGenGlobalInitializer::cmQtAutoGenGlobalInitializer(
// We support Qt4, Qt5 and Qt6
auto qtVersion = cmQtAutoGenInitializer::GetQtVersion(target);
- bool const validQt = (qtVersion.Major == 4) ||
- (qtVersion.Major == 5) || (qtVersion.Major == 6);
+ bool const validQt = (qtVersion.first.Major == 4) ||
+ (qtVersion.first.Major == 5) || (qtVersion.first.Major == 6);
bool const mocAvailable = (validQt || !mocExec.empty());
bool const uicAvailable = (validQt || !uicExec.empty());
bool const rccAvailable = (validQt || !rccExec.empty());
bool const mocIsValid = (moc && mocAvailable);
bool const uicIsValid = (uic && uicAvailable);
- bool const rccIsValid = (rcc && uicAvailable);
+ bool const rccIsValid = (rcc && rccAvailable);
// Disabled AUTOMOC/UIC/RCC warning
bool const mocDisabled = (moc && !mocAvailable);
bool const uicDisabled = (uic && !uicAvailable);
@@ -102,24 +102,18 @@ 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";
- } else {
- msg += " find_package(Qt5 COMPONENTS Core)\n";
+ {
+ std::string version = (qtVersion.second == 0)
+ ? std::string("<QTVERSION>")
+ : std::to_string(qtVersion.second);
+ std::string comp = uicDisabled ? "Widgets" : "Core";
+ msg += " find_package(Qt";
+ msg += version;
+ msg += " COMPONENTS ";
+ msg += comp;
+ msg += ")\n";
}
msg += "to your CMakeLists.txt file.";
target->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, msg);
@@ -127,7 +121,7 @@ cmQtAutoGenGlobalInitializer::cmQtAutoGenGlobalInitializer(
if (mocIsValid || uicIsValid || rccIsValid) {
// Create autogen target initializer
Initializers_.emplace_back(cm::make_unique<cmQtAutoGenInitializer>(
- this, target, qtVersion, mocIsValid, uicIsValid, rccIsValid,
+ this, target, qtVersion.first, mocIsValid, uicIsValid, rccIsValid,
globalAutoGenTarget, globalAutoRccTarget));
}
}
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index 38a4ec2..9fa8a89 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -1406,32 +1406,31 @@ static std::vector<cmQtAutoGenInitializer::IntegerVersion> GetKnownQtVersions(
return result;
}
-cmQtAutoGenInitializer::IntegerVersion cmQtAutoGenInitializer::GetQtVersion(
- cmGeneratorTarget const* target)
+std::pair<cmQtAutoGenInitializer::IntegerVersion, unsigned int>
+cmQtAutoGenInitializer::GetQtVersion(cmGeneratorTarget const* target)
{
- auto knownQtVersions = GetKnownQtVersions(target);
- if (knownQtVersions.empty()) {
- return cmQtAutoGenInitializer::IntegerVersion(); // No Qt
- }
-
- // Pick a version from the known versions:
- auto targetVersion = CharPtrToInt(
- target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", ""));
+ std::pair<IntegerVersion, unsigned int> res(
+ IntegerVersion(),
+ CharPtrToInt(target->GetLinkInterfaceDependentStringProperty(
+ "QT_MAJOR_VERSION", "")));
- if (targetVersion == 0) {
- // No specific version was requested by the target:
- // Use highest known Qt version.
- return knownQtVersions.at(0);
- }
-
- for (auto it : knownQtVersions) {
- if (it.Major == targetVersion) {
- return it;
+ auto knownQtVersions = GetKnownQtVersions(target);
+ if (!knownQtVersions.empty()) {
+ if (res.second == 0) {
+ // No specific version was requested by the target:
+ // Use highest known Qt version.
+ res.first = knownQtVersions.at(0);
+ } else {
+ // Pick a version from the known versions:
+ for (auto it : knownQtVersions) {
+ if (it.Major == res.second) {
+ res.first = it;
+ break;
+ }
+ }
}
}
-
- // Requested version was not found
- return cmQtAutoGenInitializer::IntegerVersion();
+ return res;
}
std::pair<bool, std::string> GetQtExecutable(
diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h
index 5cef1b3..47f157c 100644
--- a/Source/cmQtAutoGenInitializer.h
+++ b/Source/cmQtAutoGenInitializer.h
@@ -11,6 +11,7 @@
#include <ostream>
#include <set>
#include <string>
+#include <utility>
#include <vector>
class cmGeneratorTarget;
@@ -76,7 +77,9 @@ public:
};
public:
- static IntegerVersion GetQtVersion(cmGeneratorTarget const* target);
+ /// @return The detected Qt version and the required Qt major version
+ static std::pair<IntegerVersion, unsigned int> GetQtVersion(
+ cmGeneratorTarget const* target);
cmQtAutoGenInitializer(cmQtAutoGenGlobalInitializer* globalInitializer,
cmGeneratorTarget* target,
diff --git a/Tests/RunCMake/Autogen/NoQt-stderr.txt b/Tests/RunCMake/Autogen/NoQt-stderr.txt
index 6b4a933..1c6660a 100644
--- a/Tests/RunCMake/Autogen/NoQt-stderr.txt
+++ b/Tests/RunCMake/Autogen/NoQt-stderr.txt
@@ -1,8 +1,8 @@
^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\)
+ find_package\(Qt<QTVERSION> COMPONENTS Widgets\)
to your CMakeLists.txt file.
This warning is for project developers. Use -Wno-dev to suppress it.