Browse Source

cmCommonTargetGenerator: Adopt basic target generator members

De-duplicate the GeneratorTarget, Target, and Makefile members from the
local Makefile and Ninja generators.
Brad King 10 years ago
parent
commit
e7dcdd1011

+ 12 - 1
Source/cmCommonTargetGenerator.cxx

@@ -11,7 +11,18 @@
 ============================================================================*/
 #include "cmCommonTargetGenerator.h"
 
-cmCommonTargetGenerator::cmCommonTargetGenerator()
+#include "cmGeneratorTarget.h"
+#include "cmGlobalCommonGenerator.h"
+#include "cmLocalCommonGenerator.h"
+#include "cmTarget.h"
+
+cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt)
+  : GeneratorTarget(gt)
+  , Target(gt->Target)
+  , Makefile(gt->Makefile)
+  , LocalGenerator(static_cast<cmLocalCommonGenerator*>(gt->LocalGenerator))
+  , GlobalGenerator(static_cast<cmGlobalCommonGenerator*>(
+                      gt->LocalGenerator->GetGlobalGenerator()))
 {
 }
 

+ 14 - 1
Source/cmCommonTargetGenerator.h

@@ -14,14 +14,27 @@
 
 #include "cmStandardIncludes.h"
 
+class cmGeneratorTarget;
+class cmGlobalCommonGenerator;
+class cmLocalCommonGenerator;
+class cmMakefile;
+class cmTarget;
+
 /** \class cmCommonTargetGenerator
  * \brief Common infrastructure for Makefile and Ninja per-target generators
  */
 class cmCommonTargetGenerator
 {
 public:
-  cmCommonTargetGenerator();
+  cmCommonTargetGenerator(cmGeneratorTarget* gt);
   virtual ~cmCommonTargetGenerator();
+
+protected:
+  cmGeneratorTarget* GeneratorTarget;
+  cmTarget* Target;
+  cmMakefile* Makefile;
+  cmLocalCommonGenerator* LocalGenerator;
+  cmGlobalCommonGenerator* GlobalGenerator;
 };
 
 #endif

+ 1 - 4
Source/cmMakefileTargetGenerator.cxx

@@ -33,7 +33,7 @@
 #include <ctype.h>
 
 cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target)
-  : cmCommonTargetGenerator()
+  : cmCommonTargetGenerator(target)
   , OSXBundleGenerator(0)
   , MacOSXContentGenerator(0)
 {
@@ -42,15 +42,12 @@ cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target)
   this->FlagFileStream = 0;
   this->CustomCommandDriver = OnBuild;
   this->FortranModuleDirectoryComputed = false;
-  this->Target = target->Target;
-  this->Makefile = this->Target->GetMakefile();
   this->LocalGenerator =
     static_cast<cmLocalUnixMakefileGenerator3*>(target->GetLocalGenerator());
   this->ConfigName = this->LocalGenerator->ConfigurationName.c_str();
   this->GlobalGenerator =
     static_cast<cmGlobalUnixMakefileGenerator3*>(
       this->LocalGenerator->GetGlobalGenerator());
-  this->GeneratorTarget = target;
   cmake* cm = this->GlobalGenerator->GetCMakeInstance();
   this->NoRuleMessages = false;
   if(const char* ruleStatus = cm->GetState()

+ 0 - 3
Source/cmMakefileTargetGenerator.h

@@ -175,11 +175,8 @@ protected:
   virtual void CloseFileStreams();
   void RemoveForbiddenFlags(const char* flagVar, const std::string& linkLang,
                             std::string& linkFlags);
-  cmTarget *Target;
-  cmGeneratorTarget* GeneratorTarget;
   cmLocalUnixMakefileGenerator3 *LocalGenerator;
   cmGlobalUnixMakefileGenerator3 *GlobalGenerator;
-  cmMakefile *Makefile;
   std::string ConfigName;
 
   enum CustomCommandDriveType { OnBuild, OnDepends, OnUtility };

+ 1 - 4
Source/cmNinjaTargetGenerator.cxx

@@ -58,17 +58,14 @@ cmNinjaTargetGenerator::New(cmGeneratorTarget* target)
 }
 
 cmNinjaTargetGenerator::cmNinjaTargetGenerator(cmGeneratorTarget* target)
-  : cmCommonTargetGenerator(),
+  : cmCommonTargetGenerator(target),
     MacOSXContentGenerator(0),
     OSXBundleGenerator(0),
     MacContentFolders(),
-    Target(target->Target),
-    Makefile(target->Makefile),
     LocalGenerator(
       static_cast<cmLocalNinjaGenerator*>(target->GetLocalGenerator())),
     Objects()
 {
-  this->GeneratorTarget = target;
   MacOSXContentGenerator = new MacOSXContentGeneratorType(this);
 }
 

+ 0 - 3
Source/cmNinjaTargetGenerator.h

@@ -152,9 +152,6 @@ protected:
                             cmNinjaVars& vars);
 
 private:
-  cmTarget* Target;
-  cmGeneratorTarget* GeneratorTarget;
-  cmMakefile* Makefile;
   cmLocalNinjaGenerator* LocalGenerator;
   /// List of object files for this target.
   cmNinjaDeps Objects;