cmGlobalGenerator: Virtualize the Compute step and override it.

This commit is contained in:
Stephen Kelly 2015-07-25 19:03:51 +02:00
parent ff1019bfac
commit 5edb335485
9 changed files with 42 additions and 13 deletions

View File

@ -86,7 +86,7 @@ public:
*/ */
virtual void Configure(); virtual void Configure();
bool Compute(); virtual bool Compute();
enum TargetTypes { enum TargetTypes {
AllTargets, AllTargets,

View File

@ -314,9 +314,18 @@ cmGlobalVisualStudio10Generator::CreateLocalGenerator(cmLocalGenerator* parent,
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmGlobalVisualStudio10Generator::Compute()
{
if (!cmGlobalVisualStudio8Generator::Compute())
{
return false;
}
this->LongestSource = LongestSourcePath();
return true;
}
void cmGlobalVisualStudio10Generator::Generate() void cmGlobalVisualStudio10Generator::Generate()
{ {
this->LongestSource = LongestSourcePath();
this->cmGlobalVisualStudio8Generator::Generate(); this->cmGlobalVisualStudio8Generator::Generate();
if(this->LongestSource.Length > 0) if(this->LongestSource.Length > 0)
{ {

View File

@ -45,6 +45,8 @@ public:
std::vector<std::string> const& makeOptions = std::vector<std::string>() std::vector<std::string> const& makeOptions = std::vector<std::string>()
); );
virtual bool Compute();
///! create the correct local generator ///! create the correct local generator
virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent, virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
cmState::Snapshot snapshot); cmState::Snapshot snapshot);

View File

@ -347,8 +347,13 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalVisualStudio8Generator::Generate() bool cmGlobalVisualStudio8Generator::Compute()
{ {
if (!cmGlobalVisualStudio7Generator::Compute())
{
return false;
}
if(this->AddCheckTarget()) if(this->AddCheckTarget())
{ {
// All targets depend on the build-system check target. // All targets depend on the build-system check target.
@ -362,9 +367,7 @@ void cmGlobalVisualStudio8Generator::Generate()
} }
} }
} }
return true;
// Now perform the main generation.
this->cmGlobalVisualStudio7Generator::Generate();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -67,7 +67,7 @@ public:
return !this->WindowsCEVersion.empty(); } return !this->WindowsCEVersion.empty(); }
protected: protected:
virtual void Generate(); virtual bool Compute();
virtual const char* GetIDEVersion() { return "8.0"; } virtual const char* GetIDEVersion() { return "8.0"; }
virtual std::string FindDevEnvCommand(); virtual std::string FindDevEnvCommand();

View File

@ -64,8 +64,13 @@ std::string cmGlobalVisualStudioGenerator::GetRegistryBase(
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalVisualStudioGenerator::Generate() bool cmGlobalVisualStudioGenerator::Compute()
{ {
if (!cmGlobalGenerator::Compute())
{
return false;
}
// Add a special target that depends on ALL projects for easy build // Add a special target that depends on ALL projects for easy build
// of one configuration only. // of one configuration only.
const char* no_working_dir = 0; const char* no_working_dir = 0;
@ -136,9 +141,7 @@ void cmGlobalVisualStudioGenerator::Generate()
static_cast<cmLocalVisualStudioGenerator*>(*lgi); static_cast<cmLocalVisualStudioGenerator*>(*lgi);
lg->AddCMakeListsRules(); lg->AddCMakeListsRules();
} }
return true;
// Run all the local generators.
this->cmGlobalGenerator::Generate();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -108,7 +108,7 @@ public:
cmGeneratorTarget*, std::vector<cmCustomCommand>& commands, cmGeneratorTarget*, std::vector<cmCustomCommand>& commands,
std::string const& configName); std::string const& configName);
protected: protected:
virtual void Generate(); virtual bool Compute();
// Does this VS version link targets to each other if there are // Does this VS version link targets to each other if there are
// dependencies in the SLN file? This was done for VS versions // dependencies in the SLN file? This was done for VS versions

View File

@ -378,8 +378,13 @@ cmGlobalXCodeGenerator::CreateLocalGenerator(cmLocalGenerator* parent,
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalXCodeGenerator::Generate() bool cmGlobalXCodeGenerator::Compute()
{ {
if (!cmGlobalGenerator::Compute())
{
return false;
}
std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it; std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
// make sure extra targets are added before calling // make sure extra targets are added before calling
// the parent generate which will call trace depends // the parent generate which will call trace depends
@ -390,11 +395,17 @@ void cmGlobalXCodeGenerator::Generate()
// add ALL_BUILD, INSTALL, etc // add ALL_BUILD, INSTALL, etc
this->AddExtraTargets(root, it->second); this->AddExtraTargets(root, it->second);
} }
return true;
}
void cmGlobalXCodeGenerator::Generate()
{
this->cmGlobalGenerator::Generate(); this->cmGlobalGenerator::Generate();
if(cmSystemTools::GetErrorOccuredFlag()) if(cmSystemTools::GetErrorOccuredFlag())
{ {
return; return;
} }
std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it)
{ {
cmLocalGenerator* root = it->second[0]; cmLocalGenerator* root = it->second[0];

View File

@ -88,6 +88,7 @@ public:
virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf); virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf);
void AppendFlag(std::string& flags, std::string const& flag); void AppendFlag(std::string& flags, std::string const& flag);
protected: protected:
virtual bool Compute();
virtual void Generate(); virtual void Generate();
private: private:
cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget, cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget,