Преглед на файлове

Move automoc processing from add_executable/library to cmGlobalGenerator

Now automoc is enabled by setting the AUTOMOC target property to true,
instead of using the AUTOMOC keyword in add_executable() or add_library()

Alex
Alex Neundorf преди 14 години
родител
ревизия
50cd6cef92
променени са 4 файла, в които са добавени 36 реда и са изтрити 41 реда
  1. 1 19
      Source/cmAddExecutableCommand.cxx
  2. 1 22
      Source/cmAddLibraryCommand.cxx
  3. 32 0
      Source/cmGlobalGenerator.cxx
  4. 2 0
      Source/cmGlobalGenerator.h

+ 1 - 19
Source/cmAddExecutableCommand.cxx

@@ -10,7 +10,6 @@
   See the License for more information.
 ============================================================================*/
 #include "cmAddExecutableCommand.h"
-#include "cmQtAutomoc.h"
 
 // cmExecutableCommand
 bool cmAddExecutableCommand
@@ -30,7 +29,6 @@ bool cmAddExecutableCommand
   bool use_macbundle = false;
   bool excludeFromAll = false;
   bool importTarget = false;
-  bool doAutomoc = false;
   while ( s != args.end() )
     {
     if (*s == "WIN32")
@@ -43,11 +41,6 @@ bool cmAddExecutableCommand
       ++s;
       use_macbundle = true;
       }
-    else if ( *s == "AUTOMOC" )
-      {
-      ++s;
-      doAutomoc = true;
-      }
     else if(*s == "EXCLUDE_FROM_ALL")
       {
       ++s;
@@ -66,17 +59,12 @@ bool cmAddExecutableCommand
 
   // Special modifiers are not allowed with IMPORTED signature.
   if(importTarget
-      && (use_win32 || use_macbundle || excludeFromAll  || doAutomoc))
+      && (use_win32 || use_macbundle || excludeFromAll))
     {
     if(use_win32)
       {
       this->SetError("may not be given WIN32 for an IMPORTED target.");
       }
-    else if(doAutomoc)
-      {
-      this->SetError(
-        "may not be given AUTOMOC for an IMPORTED target.");
-      }
     else if(use_macbundle)
       {
       this->SetError(
@@ -137,11 +125,5 @@ bool cmAddExecutableCommand
     tgt->SetProperty("MACOSX_BUNDLE", "ON");
     }
 
-  if ( doAutomoc )
-    {
-    cmQtAutomoc automoc;
-    automoc.SetupAutomocTarget(tgt);
-    }
-
   return true;
 }

+ 1 - 22
Source/cmAddLibraryCommand.cxx

@@ -12,7 +12,6 @@
 #include "cmAddLibraryCommand.h"
 
 #include "cmake.h"
-#include "cmQtAutomoc.h"
 
 // cmLibraryCommand
 bool cmAddLibraryCommand
@@ -32,7 +31,6 @@ bool cmAddLibraryCommand
     }
   bool excludeFromAll = false;
   bool importTarget = false;
-  bool doAutomoc = false;
 
   std::vector<std::string>::const_iterator s = args.begin();
 
@@ -81,11 +79,6 @@ bool cmAddLibraryCommand
       ++s;
       importTarget = true;
       }
-    else if (*s == "AUTOMOC")
-      {
-      ++s;
-      doAutomoc = true;
-      }
     else
       {
       break;
@@ -120,13 +113,6 @@ bool cmAddLibraryCommand
       return false;
       }
 
-    // Don't run automoc on an imported library
-    if (doAutomoc)
-      {
-      this->SetError("cannot be called with AUTOMOC for an IMPORTED library.");
-      return false;
-      }
-
     // Make sure the target does not already exist.
     if(this->Makefile->FindTargetToUse(libName.c_str()))
       {
@@ -178,14 +164,7 @@ bool cmAddLibraryCommand
     ++s;
     }
 
-  cmTarget* tgt =this->Makefile->AddLibrary(libName.c_str(), type, srclists,
-                                            excludeFromAll);
-
-  if ( doAutomoc )
-    {
-    cmQtAutomoc automoc;
-    automoc.SetupAutomocTarget(tgt);
-    }
+  this->Makefile->AddLibrary(libName.c_str(), type, srclists, excludeFromAll);
 
   return true;
 }

+ 32 - 0
Source/cmGlobalGenerator.cxx

@@ -18,6 +18,7 @@
 #include "cmExternalMakefileProjectGenerator.h"
 #include "cmake.h"
 #include "cmMakefile.h"
+#include "cmQtAutomoc.h"
 #include "cmSourceFile.h"
 #include "cmVersion.h"
 #include "cmExportInstallFileGenerator.h"
@@ -832,6 +833,10 @@ void cmGlobalGenerator::Generate()
     return;
     }
 
+  // Iterate through all targets and set up automoc for those which have
+  // the AUTOMOC property set
+  this->CreateAutomocTargets();
+
   // For each existing cmLocalGenerator
   unsigned int i;
 
@@ -950,6 +955,33 @@ bool cmGlobalGenerator::CheckTargets()
   return true;
 }
 
+//----------------------------------------------------------------------------
+void cmGlobalGenerator::CreateAutomocTargets()
+{
+  for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
+    {
+    cmTargets& targets =
+      this->LocalGenerators[i]->GetMakefile()->GetTargets();
+    for(cmTargets::iterator ti = targets.begin();
+        ti != targets.end(); ++ti)
+      {
+      cmTarget& target = ti->second;
+      if(target.GetType() == cmTarget::EXECUTABLE ||
+         target.GetType() == cmTarget::STATIC_LIBRARY ||
+         target.GetType() == cmTarget::SHARED_LIBRARY ||
+         target.GetType() == cmTarget::MODULE_LIBRARY)
+        {
+        if(target.GetPropertyAsBool("AUTOMOC") && !target.IsImported())
+          {
+          cmQtAutomoc automoc;
+          automoc.SetupAutomocTarget(&target);
+          }
+        }
+      }
+    }
+}
+
+
 void cmGlobalGenerator::CheckLocalGenerators()
 {
   std::map<cmStdString, cmStdString> notFoundMap;

+ 2 - 0
Source/cmGlobalGenerator.h

@@ -282,6 +282,8 @@ protected:
   virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS();
 
   bool CheckTargets();
+  void CreateAutomocTargets();
+
 
   // Fill the ProjectMap, this must be called after LocalGenerators
   // has been populated.