From f5c0efdbe4d67a6f262dd670923674b003af1726 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 22 Jul 2014 15:01:05 -0400 Subject: [PATCH] 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. --- Source/cmGlobalGenerator.cxx | 7 ++++++- Source/cmGlobalGenerator.h | 4 +++- Source/cmGlobalNinjaGenerator.h | 6 +++--- Source/cmGlobalVisualStudio10Generator.h | 4 ++-- Source/cmGlobalVisualStudio6Generator.h | 8 +------- Source/cmGlobalVisualStudio7Generator.h | 8 +------- Source/cmGlobalVisualStudio8Generator.h | 2 +- Source/cmGlobalVisualStudioGenerator.h | 7 ++----- Source/cmGlobalXCodeGenerator.h | 9 ++------- Source/cmake.cxx | 2 +- 10 files changed, 22 insertions(+), 35 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 6d737b165..ae6861e0b 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1153,7 +1153,7 @@ bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const return false; } -void cmGlobalGenerator::Generate() +void cmGlobalGenerator::DoGenerate() { // Some generators track files replaced during the Generate. // Start with an empty vector: @@ -1162,6 +1162,11 @@ void cmGlobalGenerator::Generate() // clear targets to issue warning CMP0042 for this->CMP0042WarnTargets.clear(); + this->Generate(); +} + +void cmGlobalGenerator::Generate() +{ // Check whether this generator is allowed to run. if(!this->CheckALLOW_DUPLICATE_CUSTOM_TARGETS()) { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index ee3f2692c..6b608bb80 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -80,7 +80,7 @@ public: * basically creates a series of LocalGenerators for each directory and * requests that they Generate. */ - virtual void Generate(); + void DoGenerate(); /** * Set/Get and Clear the enabled languages. @@ -338,6 +338,8 @@ public: bool GenerateCPackPropertiesFile(); protected: + virtual void Generate(); + typedef std::vector GeneratorVector; // for a project collect all its targets by following depend // information, and also collect all the targets diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index ff110d7e5..4cbbeea5f 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -182,9 +182,6 @@ public: /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation() static void GetDocumentation(cmDocumentationEntry& entry); - /// Overloaded methods. @see cmGlobalGenerator::Generate() - virtual void Generate(); - /// Overloaded methods. @see cmGlobalGenerator::EnableLanguage() virtual void EnableLanguage(std::vectorconst& languages, cmMakefile* mf, @@ -302,6 +299,9 @@ public: virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: + /// Overloaded methods. @see cmGlobalGenerator::Generate() + virtual void Generate(); + /// Overloaded methods. /// @see cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const { return true; } diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index cb639dd83..9f154e94f 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -47,8 +47,6 @@ public: ///! create the correct local generator virtual cmLocalGenerator *CreateLocalGenerator(); - virtual void Generate(); - /** * Try to determine system infomation such as shared library * extension, pthreads, byte order etc. @@ -93,6 +91,8 @@ public: virtual void FindMakeProgram(cmMakefile*); protected: + virtual void Generate(); + virtual const char* GetIDEVersion() { return "10.0"; } std::string const& GetMSBuildCommand(); diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index b2fd28fad..57c2660c2 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -63,13 +63,6 @@ public: std::vector const& makeOptions = std::vector() ); - /** - * 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. */ @@ -94,6 +87,7 @@ public: virtual bool IsForVS6() const { return true; } protected: + virtual void Generate(); virtual const char* GetIDEVersion() { return "6.0"; } private: virtual std::string GetVSMakeProgram() { return this->GetMSDevCommand(); } diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index bd844333b..390b97c13 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -71,13 +71,6 @@ public: std::vector const& makeOptions = std::vector() ); - /** - * 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. */ @@ -113,6 +106,7 @@ public: virtual std::string Encoding(); protected: + virtual void Generate(); virtual const char* GetIDEVersion() { return "7.0"; } std::string const& GetDevEnvCommand(); diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index aea2f012e..d7e1f3a31 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -45,7 +45,6 @@ public: * target. */ virtual void Configure(); - virtual void Generate(); /** * Where does this version of Visual Studio look for macros for the @@ -69,6 +68,7 @@ public: return !this->WindowsCEVersion.empty(); } protected: + virtual void Generate(); virtual const char* GetIDEVersion() { return "8.0"; } virtual std::string FindDevEnvCommand(); diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 05dbb11b5..356f4d418 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -26,11 +26,6 @@ public: 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 * Studio macros directory. @@ -90,6 +85,8 @@ public: void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: + virtual void Generate(); + // Does this VS version link targets to each other if there are // dependencies in the SLN file? This was done for VS versions // below 8. diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index ae23e3bfb..fcdd34917 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -64,13 +64,6 @@ public: std::vector const& makeOptions = std::vector() ); - /** - * 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. */ virtual void AppendDirectoryForConfig(const std::string& prefix, const std::string& config, @@ -91,6 +84,8 @@ public: virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf); void AppendFlag(std::string& flags, std::string const& flag); +protected: + virtual void Generate(); private: cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget, cmSourceGroup* sg); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index a051c8760..5aa1ab0d1 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1715,7 +1715,7 @@ int cmake::Generate() { return -1; } - this->GlobalGenerator->Generate(); + this->GlobalGenerator->DoGenerate(); if ( !this->GraphVizFile.empty() ) { std::cout << "Generate graphviz: " << this->GraphVizFile << std::endl;