From 812dab067e5ea053ca36db6089507db7a5de437e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 9 Nov 2011 23:17:20 +0100 Subject: [PATCH 1/3] Don't assume the existence of QT_MAJOR_VERSION. Also handle Qt5SrcTools_MAJOR_VERSION. --- Modules/AutomocInfo.cmake.in | 1 + Source/cmQtAutomoc.cxx | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/Modules/AutomocInfo.cmake.in b/Modules/AutomocInfo.cmake.in index 2dc3aa2b3..5d440fb87 100644 --- a/Modules/AutomocInfo.cmake.in +++ b/Modules/AutomocInfo.cmake.in @@ -10,4 +10,5 @@ set(AM_QT_MOC_EXECUTABLE "@QT_MOC_EXECUTABLE@") set(AM_CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@/") set(AM_CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/") set(AM_QT_VERSION_MAJOR "@QT_VERSION_MAJOR@" ) +set(AM_Qt5SrcTools_VERSION_MAJOR "@Qt5SrcTools_VERSION_MAJOR@" ) set(AM_TARGET_NAME "@_moc_target_name@") diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index fea2e7968..045b439e9 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -51,6 +51,10 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) const char* targetName = target->GetName(); // don't do anything if there is no Qt4: std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); + if (qtMajorVersion == "") + { + qtMajorVersion = makefile->GetSafeDefinition("Qt5SrcTools_VERSION_MAJOR"); + } if (qtMajorVersion != "4" && qtMajorVersion != "5") { return; @@ -215,6 +219,10 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, } this->QtMajorVersion = makefile->GetSafeDefinition("AM_QT_VERSION_MAJOR"); + if (this->QtMajorVersion == "") + { + this->QtMajorVersion = makefile->GetSafeDefinition("AM_Qt5SrcTools_VERSION_MAJOR"); + } this->Sources = makefile->GetSafeDefinition("AM_SOURCES"); this->Headers = makefile->GetSafeDefinition("AM_HEADERS"); this->IncludeProjectDirsBefore = makefile->IsOn( From 74b9392eb9311639612d175bdc1c811560495659 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 9 Nov 2011 23:26:09 +0100 Subject: [PATCH 2/3] Update comments and method names to not be Qt4 specific. --- Source/cmQtAutomoc.cxx | 6 +++--- Source/cmQtAutomoc.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 045b439e9..861e5bb21 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -49,7 +49,7 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) { cmMakefile* makefile = target->GetMakefile(); const char* targetName = target->GetName(); - // don't do anything if there is no Qt4: + // don't do anything if there is no Qt4 or Qt5SrcTools (which contains moc): std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); if (qtMajorVersion == "") { @@ -176,7 +176,7 @@ bool cmQtAutomoc::Run(const char* targetDirectory) if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5") { - this->RunAutomocQt4(); + this->RunAutomoc(); } this->WriteOldMocDefinitionsFile(targetDirectory); @@ -380,7 +380,7 @@ void cmQtAutomoc::Init() } -bool cmQtAutomoc::RunAutomocQt4() +bool cmQtAutomoc::RunAutomoc() { if (!cmsys::SystemTools::FileExists(this->OutMocCppFilename.c_str()) || (this->OldMocDefinitionsStr != this->Join(this->MocDefinitions, ' '))) diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutomoc.h index c3550a42d..59eaac760 100644 --- a/Source/cmQtAutomoc.h +++ b/Source/cmQtAutomoc.h @@ -35,7 +35,7 @@ private: const char* targetDirectory); void WriteOldMocDefinitionsFile(const char* targetDirectory); - bool RunAutomocQt4(); + bool RunAutomoc(); bool GenerateMoc(const std::string& sourceFile, const std::string& mocFileName); void ParseCppFile(const std::string& absFilename, From bafe5cc6e90ebb510dfe992c8a7a1eca55826813 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 10 Nov 2011 00:57:21 +0100 Subject: [PATCH 3/3] Fix style. --- Source/cmQtAutomoc.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 861e5bb21..72249bcc0 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -53,7 +53,7 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); if (qtMajorVersion == "") { - qtMajorVersion = makefile->GetSafeDefinition("Qt5SrcTools_VERSION_MAJOR"); + qtMajorVersion = makefile->GetSafeDefinition("Qt5SrcTools_VERSION_MAJOR"); } if (qtMajorVersion != "4" && qtMajorVersion != "5") { @@ -221,7 +221,8 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, this->QtMajorVersion = makefile->GetSafeDefinition("AM_QT_VERSION_MAJOR"); if (this->QtMajorVersion == "") { - this->QtMajorVersion = makefile->GetSafeDefinition("AM_Qt5SrcTools_VERSION_MAJOR"); + this->QtMajorVersion = makefile->GetSafeDefinition( + "AM_Qt5SrcTools_VERSION_MAJOR"); } this->Sources = makefile->GetSafeDefinition("AM_SOURCES"); this->Headers = makefile->GetSafeDefinition("AM_HEADERS");