Browse Source

Autogen: Add (CMAKE_)AUTOMOC_COMPILER_PREDEFINES

Sebastian Holtermann 8 years ago
parent
commit
1d7f099d9c
3 changed files with 10 additions and 5 deletions
  1. 1 0
      Modules/CMakeGenericSystem.cmake
  2. 8 5
      Source/cmQtAutoGeneratorInitializer.cxx
  3. 1 0
      Source/cmTarget.cxx

+ 1 - 0
Modules/CMakeGenericSystem.cmake

@@ -23,6 +23,7 @@ set(CMAKE_DL_LIBS "dl")
 
 set(CMAKE_FIND_LIBRARY_PREFIXES "lib")
 set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a")
+set(CMAKE_AUTOMOC_COMPILER_PREDEFINES ON)
 set(CMAKE_AUTOMOC_MACRO_NAMES "Q_OBJECT" "Q_GADGET" "Q_NAMESPACE")
 
 # basically all general purpose OSs support shared libs

+ 8 - 5
Source/cmQtAutoGeneratorInitializer.cxx

@@ -363,11 +363,14 @@ static void SetupAutoTargetMoc(cmQtAutoGenDigest const& digest,
   AddDefinitionEscaped(makefile, "_moc_depend_filters",
                        GetSafeProperty(target, "AUTOMOC_DEPEND_FILTERS"));
 
-  if (QtVersionGreaterOrEqual(digest.QtVersionMajor, digest.QtVersionMinor, 5,
-                              8)) {
-    AddDefinitionEscaped(
-      makefile, "_moc_predefs_cmd",
-      makefile->GetSafeDefinition("CMAKE_CXX_COMPILER_PREDEFINES_COMMAND"));
+  // Compiler predefines
+  if (target->GetPropertyAsBool("AUTOMOC_COMPILER_PREDEFINES")) {
+    if (QtVersionGreaterOrEqual(digest.QtVersionMajor, digest.QtVersionMinor,
+                                5, 8)) {
+      AddDefinitionEscaped(
+        makefile, "_moc_predefs_cmd",
+        makefile->GetSafeDefinition("CMAKE_CXX_COMPILER_PREDEFINES_COMMAND"));
+    }
   }
   // Moc includes and compile definitions
   {

+ 1 - 0
Source/cmTarget.cxx

@@ -244,6 +244,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
     this->SetPropertyDefault("AUTOMOC", nullptr);
     this->SetPropertyDefault("AUTOUIC", nullptr);
     this->SetPropertyDefault("AUTORCC", nullptr);
+    this->SetPropertyDefault("AUTOMOC_COMPILER_PREDEFINES", nullptr);
     this->SetPropertyDefault("AUTOMOC_DEPEND_FILTERS", nullptr);
     this->SetPropertyDefault("AUTOMOC_MACRO_NAMES", nullptr);
     this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", nullptr);