Commit 6a23e16e authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'autogen_noqt_warning'

0377fe1e Merge branch 'backport-autogen_noqt_warning' into autogen_noqt_warning
dd39da55 Tests: Add case for warning when AUTOMOC/UIC/RCC gets disabled
f44a0414 Autogen: Issue a warning when AUTOMOC/UIC/RCC gets disabled.
5ae69f59

 Autogen: Issue a warning when AUTOMOC/UIC/RCC gets disabled.
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !2787
parents dd90811b 0377fe1e
Pipeline #127580 passed with stage
in 0 seconds
......@@ -13,6 +13,7 @@
#include "cmStateTypes.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmake.h"
#include <memory>
#include <utility>
......@@ -86,10 +87,43 @@ cmQtAutoGenGlobalInitializer::cmQtAutoGenGlobalInitializer(
auto qtVersion = cmQtAutoGenInitializer::GetQtVersion(target);
bool const validQt = (qtVersion.Major == 4) ||
(qtVersion.Major == 5) || (qtVersion.Major == 6);
bool const mocIsValid = moc && (validQt || !mocExec.empty());
bool const uicIsValid = uic && (validQt || !uicExec.empty());
bool const rccIsValid = rcc && (validQt || !rccExec.empty());
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);
// Disabled AUTOMOC/UIC/RCC warning
bool const mocDisabled = (moc && !mocAvailable);
bool const uicDisabled = (uic && !uicAvailable);
bool const rccDisabled = (rcc && !rccAvailable);
if (mocDisabled || uicDisabled || rccDisabled) {
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 += " disabled. Consider adding:\n";
if (uicDisabled) {
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);
}
if (mocIsValid || uicIsValid || rccIsValid) {
// Create autogen target initializer
Initializers_.emplace_back(cm::make_unique<cmQtAutoGenInitializer>(
......
cmake_minimum_required(VERSION 3.13)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)
^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.
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)
include(RunCMake)
run_cmake(NoQt)
......@@ -150,6 +150,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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment