summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoGenGlobalInitializer.cxx
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2018-11-05 10:18:46 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2018-11-11 08:35:28 (GMT)
commit3327d3bb20c2a4505648b59d72cfaada38e1ee93 (patch)
tree6a6053f75255956b59a6828459a3756c2e6301a9 /Source/cmQtAutoGenGlobalInitializer.cxx
parent206ce3c0ba730f34444a8627d6a4f261bf60fc92 (diff)
downloadCMake-3327d3bb20c2a4505648b59d72cfaada38e1ee93.zip
CMake-3327d3bb20c2a4505648b59d72cfaada38e1ee93.tar.gz
CMake-3327d3bb20c2a4505648b59d72cfaada38e1ee93.tar.bz2
Autogen: Add cmQtAutoGenGlobalInitializer class
This moves the global ``AUTOMOC/UIC/RCC`` targets initializer generation code into a separate new ``cmQtAutoGenGlobalInitializer`` class.
Diffstat (limited to 'Source/cmQtAutoGenGlobalInitializer.cxx')
-rw-r--r--Source/cmQtAutoGenGlobalInitializer.cxx76
1 files changed, 76 insertions, 0 deletions
diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx
new file mode 100644
index 0000000..d815a43
--- /dev/null
+++ b/Source/cmQtAutoGenGlobalInitializer.cxx
@@ -0,0 +1,76 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmQtAutoGenGlobalInitializer.h"
+#include "cmAlgorithms.h"
+#include "cmGeneratorTarget.h"
+#include "cmLocalGenerator.h"
+#include "cmQtAutoGenInitializer.h"
+
+cmQtAutoGenGlobalInitializer::cmQtAutoGenGlobalInitializer(
+ std::vector<cmLocalGenerator*> const& localGenerators)
+{
+ for (cmLocalGenerator* localGen : localGenerators) {
+ // Find targets that require AUTOMOC/UIC/RCC processing
+ for (cmGeneratorTarget* target : localGen->GetGeneratorTargets()) {
+ // Process only certain target types
+ switch (target->GetType()) {
+ case cmStateEnums::EXECUTABLE:
+ case cmStateEnums::STATIC_LIBRARY:
+ case cmStateEnums::SHARED_LIBRARY:
+ case cmStateEnums::MODULE_LIBRARY:
+ case cmStateEnums::OBJECT_LIBRARY:
+ // Process target
+ break;
+ default:
+ // Don't process target
+ continue;
+ }
+ if (target->IsImported()) {
+ // Don't process target
+ continue;
+ }
+
+ bool const moc = target->GetPropertyAsBool("AUTOMOC");
+ bool const uic = target->GetPropertyAsBool("AUTOUIC");
+ bool const rcc = target->GetPropertyAsBool("AUTORCC");
+ if (moc || uic || rcc) {
+ // We support Qt4 and Qt5
+ auto qtVersion = cmQtAutoGenInitializer::GetQtVersion(target);
+ if ((qtVersion.Major == 4) || (qtVersion.Major == 5)) {
+ // Create autogen target initializer
+ Initializers_.emplace_back(cm::make_unique<cmQtAutoGenInitializer>(
+ target, moc, uic, rcc, qtVersion));
+ }
+ }
+ }
+ }
+}
+
+cmQtAutoGenGlobalInitializer::~cmQtAutoGenGlobalInitializer()
+{
+}
+
+bool cmQtAutoGenGlobalInitializer::generate()
+{
+ return (InitializeCustomTargets() && SetupCustomTargets());
+}
+
+bool cmQtAutoGenGlobalInitializer::InitializeCustomTargets()
+{
+ for (auto& autoGen : Initializers_) {
+ if (!autoGen->InitCustomTargets()) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool cmQtAutoGenGlobalInitializer::SetupCustomTargets()
+{
+ for (auto& autoGen : Initializers_) {
+ if (!autoGen->SetupCustomTargets()) {
+ return false;
+ }
+ }
+ return true;
+}