summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-01-11 16:25:59 (GMT)
committerBrad King <brad.king@kitware.com>2019-01-11 16:25:59 (GMT)
commitddb5b097cd29e2e7fcddcb79c4e3ae8c64b0a5b3 (patch)
treeda212dc5a024734ee2b676fc9f08895007dc3699
parent91fa6a472cd262014a74d765b003bb1cc9d7ab8a (diff)
parentdd39da551883bca5f8ec1be376a77f6d56666552 (diff)
downloadCMake-ddb5b097cd29e2e7fcddcb79c4e3ae8c64b0a5b3.zip
CMake-ddb5b097cd29e2e7fcddcb79c4e3ae8c64b0a5b3.tar.gz
CMake-ddb5b097cd29e2e7fcddcb79c4e3ae8c64b0a5b3.tar.bz2
Merge branch 'backport-autogen_noqt_warning' into release-3.13
Merge-request: !2787
-rw-r--r--Source/cmGlobalGenerator.cxx25
-rw-r--r--Tests/RunCMake/Autogen/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/Autogen/NoQt-stderr.txt8
-rw-r--r--Tests/RunCMake/Autogen/NoQt.cmake6
-rw-r--r--Tests/RunCMake/Autogen/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/Autogen/empty.cpp0
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
7 files changed, 46 insertions, 0 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 71e844e..5f7ff0b 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1500,6 +1500,31 @@ bool cmGlobalGenerator::QtAutoGen()
auto qtVersion = cmQtAutoGenInitializer::GetQtVersion(target);
// don't do anything if there is no Qt4 or Qt5Core (which contains moc)
if (qtVersion.Major != 4 && qtVersion.Major != 5) {
+ std::string msg = "AUTOGEN: No valid Qt version found for target ";
+ msg += target->GetName();
+ msg += ". ";
+ {
+ std::vector<std::string> lst;
+ if (mocEnabled) {
+ lst.emplace_back("AUTOMOC");
+ }
+ if (uicEnabled) {
+ lst.emplace_back("AUTOUIC");
+ }
+ if (rccEnabled) {
+ lst.emplace_back("AUTORCC");
+ }
+ msg += cmJoin(lst, ", ");
+ }
+ msg += " disabled. ";
+ msg += "Consider adding:\n";
+ if (uicEnabled) {
+ msg += " find_package(Qt5 COMPONENTS Widgets)\n";
+ } else {
+ msg += " find_package(Qt5 COMPONENTS Core)\n";
+ }
+ msg += "to your CMakeLists.txt file.";
+ target->Makefile->IssueMessage(cmake::AUTHOR_WARNING, msg);
continue;
}
diff --git a/Tests/RunCMake/Autogen/CMakeLists.txt b/Tests/RunCMake/Autogen/CMakeLists.txt
new file mode 100644
index 0000000..9a66cde
--- /dev/null
+++ b/Tests/RunCMake/Autogen/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.13)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/Autogen/NoQt-stderr.txt b/Tests/RunCMake/Autogen/NoQt-stderr.txt
new file mode 100644
index 0000000..6b4a933
--- /dev/null
+++ b/Tests/RunCMake/Autogen/NoQt-stderr.txt
@@ -0,0 +1,8 @@
+^CMake Warning \(dev\) in CMakeLists.txt:
+ AUTOGEN: No valid Qt version found for target main. AUTOMOC, AUTOUIC,
+ AUTORCC disabled. Consider adding:
+
+ find_package\(Qt5 COMPONENTS Widgets\)
+
+ to your CMakeLists.txt file.
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/Autogen/NoQt.cmake b/Tests/RunCMake/Autogen/NoQt.cmake
new file mode 100644
index 0000000..b2d375a
--- /dev/null
+++ b/Tests/RunCMake/Autogen/NoQt.cmake
@@ -0,0 +1,6 @@
+enable_language(CXX)
+
+add_executable(main empty.cpp)
+set_property(TARGET main PROPERTY AUTOMOC 1)
+set_property(TARGET main PROPERTY AUTORCC 1)
+set_property(TARGET main PROPERTY AUTOUIC 1)
diff --git a/Tests/RunCMake/Autogen/RunCMakeTest.cmake b/Tests/RunCMake/Autogen/RunCMakeTest.cmake
new file mode 100644
index 0000000..e52f28d
--- /dev/null
+++ b/Tests/RunCMake/Autogen/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(NoQt)
diff --git a/Tests/RunCMake/Autogen/empty.cpp b/Tests/RunCMake/Autogen/empty.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/Autogen/empty.cpp
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 99f4ae7..89102dd 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -142,6 +142,7 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE)
endif()
add_RunCMake_test(AndroidTestUtilities)
+add_RunCMake_test(Autogen)
add_RunCMake_test(BuildDepends)
if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja")
add_RunCMake_test(Byproducts)