cmGlobalGenerator: Create a non-virtual 'DoGenerate' method

Make the virtual 'Generate' method protected.  Make 'DoGenerate'
the main entry point to generation.  This gives cmGlobalGenerator
a chance to do some early operations before the individual
generator-specific implementations take over.
This commit is contained in:
Brad King 2014-07-22 15:01:05 -04:00
parent 5c38fc1628
commit f5c0efdbe4
10 changed files with 22 additions and 35 deletions

View File

@ -1153,7 +1153,7 @@ bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const
return false; return false;
} }
void cmGlobalGenerator::Generate() void cmGlobalGenerator::DoGenerate()
{ {
// Some generators track files replaced during the Generate. // Some generators track files replaced during the Generate.
// Start with an empty vector: // Start with an empty vector:
@ -1162,6 +1162,11 @@ void cmGlobalGenerator::Generate()
// clear targets to issue warning CMP0042 for // clear targets to issue warning CMP0042 for
this->CMP0042WarnTargets.clear(); this->CMP0042WarnTargets.clear();
this->Generate();
}
void cmGlobalGenerator::Generate()
{
// Check whether this generator is allowed to run. // Check whether this generator is allowed to run.
if(!this->CheckALLOW_DUPLICATE_CUSTOM_TARGETS()) if(!this->CheckALLOW_DUPLICATE_CUSTOM_TARGETS())
{ {

View File

@ -80,7 +80,7 @@ public:
* basically creates a series of LocalGenerators for each directory and * basically creates a series of LocalGenerators for each directory and
* requests that they Generate. * requests that they Generate.
*/ */
virtual void Generate(); void DoGenerate();
/** /**
* Set/Get and Clear the enabled languages. * Set/Get and Clear the enabled languages.
@ -338,6 +338,8 @@ public:
bool GenerateCPackPropertiesFile(); bool GenerateCPackPropertiesFile();
protected: protected:
virtual void Generate();
typedef std::vector<cmLocalGenerator*> GeneratorVector; typedef std::vector<cmLocalGenerator*> GeneratorVector;
// for a project collect all its targets by following depend // for a project collect all its targets by following depend
// information, and also collect all the targets // information, and also collect all the targets

View File

@ -182,9 +182,6 @@ public:
/// Overloaded methods. @see cmGlobalGenerator::GetDocumentation() /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation()
static void GetDocumentation(cmDocumentationEntry& entry); static void GetDocumentation(cmDocumentationEntry& entry);
/// Overloaded methods. @see cmGlobalGenerator::Generate()
virtual void Generate();
/// Overloaded methods. @see cmGlobalGenerator::EnableLanguage() /// Overloaded methods. @see cmGlobalGenerator::EnableLanguage()
virtual void EnableLanguage(std::vector<std::string>const& languages, virtual void EnableLanguage(std::vector<std::string>const& languages,
cmMakefile* mf, cmMakefile* mf,
@ -302,6 +299,9 @@ public:
virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
protected: protected:
/// Overloaded methods. @see cmGlobalGenerator::Generate()
virtual void Generate();
/// Overloaded methods. /// Overloaded methods.
/// @see cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() /// @see cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS()
virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const { return true; } virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const { return true; }

View File

@ -47,8 +47,6 @@ public:
///! create the correct local generator ///! create the correct local generator
virtual cmLocalGenerator *CreateLocalGenerator(); virtual cmLocalGenerator *CreateLocalGenerator();
virtual void Generate();
/** /**
* Try to determine system infomation such as shared library * Try to determine system infomation such as shared library
* extension, pthreads, byte order etc. * extension, pthreads, byte order etc.
@ -93,6 +91,8 @@ public:
virtual void FindMakeProgram(cmMakefile*); virtual void FindMakeProgram(cmMakefile*);
protected: protected:
virtual void Generate();
virtual const char* GetIDEVersion() { return "10.0"; } virtual const char* GetIDEVersion() { return "10.0"; }
std::string const& GetMSBuildCommand(); std::string const& GetMSBuildCommand();

View File

@ -63,13 +63,6 @@ public:
std::vector<std::string> const& makeOptions = std::vector<std::string>() std::vector<std::string> const& makeOptions = std::vector<std::string>()
); );
/**
* Generate the all required files for building this project/tree. This
* basically creates a series of LocalGenerators for each directory and
* requests that they Generate.
*/
virtual void Generate();
/** /**
* Generate the DSW workspace file. * Generate the DSW workspace file.
*/ */
@ -94,6 +87,7 @@ public:
virtual bool IsForVS6() const { return true; } virtual bool IsForVS6() const { return true; }
protected: protected:
virtual void Generate();
virtual const char* GetIDEVersion() { return "6.0"; } virtual const char* GetIDEVersion() { return "6.0"; }
private: private:
virtual std::string GetVSMakeProgram() { return this->GetMSDevCommand(); } virtual std::string GetVSMakeProgram() { return this->GetMSDevCommand(); }

View File

@ -71,13 +71,6 @@ public:
std::vector<std::string> const& makeOptions = std::vector<std::string>() std::vector<std::string> const& makeOptions = std::vector<std::string>()
); );
/**
* Generate the all required files for building this project/tree. This
* basically creates a series of LocalGenerators for each directory and
* requests that they Generate.
*/
virtual void Generate();
/** /**
* Generate the DSW workspace file. * Generate the DSW workspace file.
*/ */
@ -113,6 +106,7 @@ public:
virtual std::string Encoding(); virtual std::string Encoding();
protected: protected:
virtual void Generate();
virtual const char* GetIDEVersion() { return "7.0"; } virtual const char* GetIDEVersion() { return "7.0"; }
std::string const& GetDevEnvCommand(); std::string const& GetDevEnvCommand();

View File

@ -45,7 +45,6 @@ public:
* target. * target.
*/ */
virtual void Configure(); virtual void Configure();
virtual void Generate();
/** /**
* Where does this version of Visual Studio look for macros for the * Where does this version of Visual Studio look for macros for the
@ -69,6 +68,7 @@ public:
return !this->WindowsCEVersion.empty(); } return !this->WindowsCEVersion.empty(); }
protected: protected:
virtual void Generate();
virtual const char* GetIDEVersion() { return "8.0"; } virtual const char* GetIDEVersion() { return "8.0"; }
virtual std::string FindDevEnvCommand(); virtual std::string FindDevEnvCommand();

View File

@ -26,11 +26,6 @@ public:
cmGlobalVisualStudioGenerator(); cmGlobalVisualStudioGenerator();
virtual ~cmGlobalVisualStudioGenerator(); virtual ~cmGlobalVisualStudioGenerator();
/**
* Basic generate implementation for all VS generators.
*/
virtual void Generate();
/** /**
* Configure CMake's Visual Studio macros file into the user's Visual * Configure CMake's Visual Studio macros file into the user's Visual
* Studio macros directory. * Studio macros directory.
@ -90,6 +85,8 @@ public:
void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
protected: protected:
virtual void Generate();
// 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
// below 8. // below 8.

View File

@ -64,13 +64,6 @@ public:
std::vector<std::string> const& makeOptions = std::vector<std::string>() std::vector<std::string> const& makeOptions = std::vector<std::string>()
); );
/**
* Generate the all required files for building this project/tree. This
* basically creates a series of LocalGenerators for each directory and
* requests that they Generate.
*/
virtual void Generate();
/** Append the subdirectory for the given configuration. */ /** Append the subdirectory for the given configuration. */
virtual void AppendDirectoryForConfig(const std::string& prefix, virtual void AppendDirectoryForConfig(const std::string& prefix,
const std::string& config, const std::string& config,
@ -91,6 +84,8 @@ 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:
virtual void Generate();
private: private:
cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget, cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget,
cmSourceGroup* sg); cmSourceGroup* sg);

View File

@ -1715,7 +1715,7 @@ int cmake::Generate()
{ {
return -1; return -1;
} }
this->GlobalGenerator->Generate(); this->GlobalGenerator->DoGenerate();
if ( !this->GraphVizFile.empty() ) if ( !this->GraphVizFile.empty() )
{ {
std::cout << "Generate graphviz: " << this->GraphVizFile << std::endl; std::cout << "Generate graphviz: " << this->GraphVizFile << std::endl;