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
This commit is contained in:
parent
cbaac2a587
commit
50cd6cef92
|
@ -10,7 +10,6 @@
|
||||||
See the License for more information.
|
See the License for more information.
|
||||||
============================================================================*/
|
============================================================================*/
|
||||||
#include "cmAddExecutableCommand.h"
|
#include "cmAddExecutableCommand.h"
|
||||||
#include "cmQtAutomoc.h"
|
|
||||||
|
|
||||||
// cmExecutableCommand
|
// cmExecutableCommand
|
||||||
bool cmAddExecutableCommand
|
bool cmAddExecutableCommand
|
||||||
|
@ -30,7 +29,6 @@ bool cmAddExecutableCommand
|
||||||
bool use_macbundle = false;
|
bool use_macbundle = false;
|
||||||
bool excludeFromAll = false;
|
bool excludeFromAll = false;
|
||||||
bool importTarget = false;
|
bool importTarget = false;
|
||||||
bool doAutomoc = false;
|
|
||||||
while ( s != args.end() )
|
while ( s != args.end() )
|
||||||
{
|
{
|
||||||
if (*s == "WIN32")
|
if (*s == "WIN32")
|
||||||
|
@ -43,11 +41,6 @@ bool cmAddExecutableCommand
|
||||||
++s;
|
++s;
|
||||||
use_macbundle = true;
|
use_macbundle = true;
|
||||||
}
|
}
|
||||||
else if ( *s == "AUTOMOC" )
|
|
||||||
{
|
|
||||||
++s;
|
|
||||||
doAutomoc = true;
|
|
||||||
}
|
|
||||||
else if(*s == "EXCLUDE_FROM_ALL")
|
else if(*s == "EXCLUDE_FROM_ALL")
|
||||||
{
|
{
|
||||||
++s;
|
++s;
|
||||||
|
@ -66,17 +59,12 @@ bool cmAddExecutableCommand
|
||||||
|
|
||||||
// Special modifiers are not allowed with IMPORTED signature.
|
// Special modifiers are not allowed with IMPORTED signature.
|
||||||
if(importTarget
|
if(importTarget
|
||||||
&& (use_win32 || use_macbundle || excludeFromAll || doAutomoc))
|
&& (use_win32 || use_macbundle || excludeFromAll))
|
||||||
{
|
{
|
||||||
if(use_win32)
|
if(use_win32)
|
||||||
{
|
{
|
||||||
this->SetError("may not be given WIN32 for an IMPORTED target.");
|
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)
|
else if(use_macbundle)
|
||||||
{
|
{
|
||||||
this->SetError(
|
this->SetError(
|
||||||
|
@ -137,11 +125,5 @@ bool cmAddExecutableCommand
|
||||||
tgt->SetProperty("MACOSX_BUNDLE", "ON");
|
tgt->SetProperty("MACOSX_BUNDLE", "ON");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( doAutomoc )
|
|
||||||
{
|
|
||||||
cmQtAutomoc automoc;
|
|
||||||
automoc.SetupAutomocTarget(tgt);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include "cmAddLibraryCommand.h"
|
#include "cmAddLibraryCommand.h"
|
||||||
|
|
||||||
#include "cmake.h"
|
#include "cmake.h"
|
||||||
#include "cmQtAutomoc.h"
|
|
||||||
|
|
||||||
// cmLibraryCommand
|
// cmLibraryCommand
|
||||||
bool cmAddLibraryCommand
|
bool cmAddLibraryCommand
|
||||||
|
@ -32,7 +31,6 @@ bool cmAddLibraryCommand
|
||||||
}
|
}
|
||||||
bool excludeFromAll = false;
|
bool excludeFromAll = false;
|
||||||
bool importTarget = false;
|
bool importTarget = false;
|
||||||
bool doAutomoc = false;
|
|
||||||
|
|
||||||
std::vector<std::string>::const_iterator s = args.begin();
|
std::vector<std::string>::const_iterator s = args.begin();
|
||||||
|
|
||||||
|
@ -81,11 +79,6 @@ bool cmAddLibraryCommand
|
||||||
++s;
|
++s;
|
||||||
importTarget = true;
|
importTarget = true;
|
||||||
}
|
}
|
||||||
else if (*s == "AUTOMOC")
|
|
||||||
{
|
|
||||||
++s;
|
|
||||||
doAutomoc = true;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -120,13 +113,6 @@ bool cmAddLibraryCommand
|
||||||
return false;
|
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.
|
// Make sure the target does not already exist.
|
||||||
if(this->Makefile->FindTargetToUse(libName.c_str()))
|
if(this->Makefile->FindTargetToUse(libName.c_str()))
|
||||||
{
|
{
|
||||||
|
@ -178,14 +164,7 @@ bool cmAddLibraryCommand
|
||||||
++s;
|
++s;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmTarget* tgt =this->Makefile->AddLibrary(libName.c_str(), type, srclists,
|
this->Makefile->AddLibrary(libName.c_str(), type, srclists, excludeFromAll);
|
||||||
excludeFromAll);
|
|
||||||
|
|
||||||
if ( doAutomoc )
|
|
||||||
{
|
|
||||||
cmQtAutomoc automoc;
|
|
||||||
automoc.SetupAutomocTarget(tgt);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "cmExternalMakefileProjectGenerator.h"
|
#include "cmExternalMakefileProjectGenerator.h"
|
||||||
#include "cmake.h"
|
#include "cmake.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
|
#include "cmQtAutomoc.h"
|
||||||
#include "cmSourceFile.h"
|
#include "cmSourceFile.h"
|
||||||
#include "cmVersion.h"
|
#include "cmVersion.h"
|
||||||
#include "cmExportInstallFileGenerator.h"
|
#include "cmExportInstallFileGenerator.h"
|
||||||
|
@ -832,6 +833,10 @@ void cmGlobalGenerator::Generate()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Iterate through all targets and set up automoc for those which have
|
||||||
|
// the AUTOMOC property set
|
||||||
|
this->CreateAutomocTargets();
|
||||||
|
|
||||||
// For each existing cmLocalGenerator
|
// For each existing cmLocalGenerator
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
@ -950,6 +955,33 @@ bool cmGlobalGenerator::CheckTargets()
|
||||||
return true;
|
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()
|
void cmGlobalGenerator::CheckLocalGenerators()
|
||||||
{
|
{
|
||||||
std::map<cmStdString, cmStdString> notFoundMap;
|
std::map<cmStdString, cmStdString> notFoundMap;
|
||||||
|
|
|
@ -282,6 +282,8 @@ protected:
|
||||||
virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS();
|
virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS();
|
||||||
|
|
||||||
bool CheckTargets();
|
bool CheckTargets();
|
||||||
|
void CreateAutomocTargets();
|
||||||
|
|
||||||
|
|
||||||
// Fill the ProjectMap, this must be called after LocalGenerators
|
// Fill the ProjectMap, this must be called after LocalGenerators
|
||||||
// has been populated.
|
// has been populated.
|
||||||
|
|
Loading…
Reference in New Issue