cmCommonTargetGenerator: Adopt basic target generator members

De-duplicate the GeneratorTarget, Target, and Makefile members from the
local Makefile and Ninja generators.
This commit is contained in:
Brad King 2015-07-08 11:13:11 -04:00
parent 001f9b3617
commit e7dcdd1011
6 changed files with 28 additions and 16 deletions

View File

@ -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()))
{
}

View File

@ -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

View File

@ -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()

View File

@ -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 };

View File

@ -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);
}

View File

@ -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;