diff options
Diffstat (limited to 'Source/cmQtAutoGenGlobalInitializer.cxx')
-rw-r--r-- | Source/cmQtAutoGenGlobalInitializer.cxx | 55 |
1 files changed, 51 insertions, 4 deletions
diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx index 5470ec3..cdd96ce 100644 --- a/Source/cmQtAutoGenGlobalInitializer.cxx +++ b/Source/cmQtAutoGenGlobalInitializer.cxx @@ -9,6 +9,7 @@ #include "cmGeneratorTarget.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" +#include "cmMessageType.h" #include "cmState.h" #include "cmStateTypes.h" #include "cmSystemTools.h" @@ -75,13 +76,59 @@ cmQtAutoGenGlobalInitializer::cmQtAutoGenGlobalInitializer( bool const uic = target->GetPropertyAsBool("AUTOUIC"); bool const rcc = target->GetPropertyAsBool("AUTORCC"); if (moc || uic || rcc) { - // We support Qt4 and Qt5 + std::string const mocExec = + target->GetSafeProperty("AUTOMOC_EXECUTABLE"); + std::string const uicExec = + target->GetSafeProperty("AUTOUIC_EXECUTABLE"); + std::string const rccExec = + target->GetSafeProperty("AUTORCC_EXECUTABLE"); + + // We support Qt4, Qt5 and Qt6 auto qtVersion = cmQtAutoGenInitializer::GetQtVersion(target); - if ((qtVersion.Major == 4) || (qtVersion.Major == 5)) { + bool const validQt = (qtVersion.Major == 4) || + (qtVersion.Major == 5) || (qtVersion.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); + // 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(MessageType::AUTHOR_WARNING, msg); + } + if (mocIsValid || uicIsValid || rccIsValid) { // Create autogen target initializer Initializers_.emplace_back(cm::make_unique<cmQtAutoGenInitializer>( - this, target, qtVersion, moc, uic, rcc, globalAutoGenTarget, - globalAutoRccTarget)); + this, target, qtVersion, mocIsValid, uicIsValid, rccIsValid, + globalAutoGenTarget, globalAutoRccTarget)); } } } |