Merge branch 'fix-automoc-compile-definitions' into release
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index e8a4bb6..f297c4a 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -964,6 +964,8 @@
     return;
     }
 
+  this->FinalizeTargetCompileDefinitions();
+
   // Iterate through all targets and set up automoc for those which have
   // the AUTOMOC property set
   this->CreateAutomocTargets();
@@ -1149,13 +1151,11 @@
 }
 
 //----------------------------------------------------------------------------
-void cmGlobalGenerator::CreateGeneratorTargets()
+void cmGlobalGenerator::FinalizeTargetCompileDefinitions()
 {
   // Construct per-target generator information.
   for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
     {
-    cmGeneratorTargetsType generatorTargets;
-
     cmMakefile *mf = this->LocalGenerators[i]->GetMakefile();
 
     const std::vector<cmValueWithOrigin> noconfig_compile_definitions =
@@ -1170,7 +1170,6 @@
       {
       cmTarget* t = &ti->second;
 
-      {
       for (std::vector<cmValueWithOrigin>::const_iterator it
                                       = noconfig_compile_definitions.begin();
           it != noconfig_compile_definitions.end(); ++it)
@@ -1187,7 +1186,24 @@
                           mf->GetProperty(defPropName.c_str()));
         }
       }
+    }
+}
 
+//----------------------------------------------------------------------------
+void cmGlobalGenerator::CreateGeneratorTargets()
+{
+  // Construct per-target generator information.
+  for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
+    {
+    cmGeneratorTargetsType generatorTargets;
+
+    cmMakefile *mf = this->LocalGenerators[i]->GetMakefile();
+
+    cmTargets& targets = mf->GetTargets();
+    for(cmTargets::iterator ti = targets.begin();
+        ti != targets.end(); ++ti)
+      {
+      cmTarget* t = &ti->second;
       cmGeneratorTarget* gt = new cmGeneratorTarget(t);
       this->GeneratorTargets[t] = gt;
       this->ComputeTargetObjects(gt);
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 18aba24..80916ae 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -382,6 +382,7 @@
 
   void WriteSummary();
   void WriteSummary(cmTarget* target);
+  void FinalizeTargetCompileDefinitions();
 
   cmExternalMakefileProjectGenerator* ExtraGenerator;
 
diff --git a/Tests/QtAutomoc/foo.h b/Tests/QtAutomoc/foo.h
index 32d4c8d..f23ec07 100644
--- a/Tests/QtAutomoc/foo.h
+++ b/Tests/QtAutomoc/foo.h
@@ -16,7 +16,10 @@
 
 #include <QObject>
 
-class Foo : public QObject
+class Foo
+#ifdef FOO
+          : public QObject
+#endif
 {
   Q_OBJECT
   public: