diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index ef75b3b06..bac243039 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/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; } diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index f0b2e0d43..efa29e6c9 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/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::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; } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index f37b0549d..3016f5a68 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/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 notFoundMap; diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index b7b1bff82..88eb8b61a 100644 --- a/Source/cmGlobalGenerator.h +++ b/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.