cmLocalGenerator: Create from already-constructed cmMakefile.

Don't manage the lifetime of the cmMakefile with cmLocalGenerator.
This commit is contained in:
Stephen Kelly 2015-08-02 11:41:51 +02:00
parent 0bd7279fd9
commit ff8ac8ee6a
49 changed files with 112 additions and 116 deletions

View File

@ -716,9 +716,10 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
cm.AddCMakePaths(); cm.AddCMakePaths();
cm.SetProgressCallback(cmCPackGeneratorProgress, this); cm.SetProgressCallback(cmCPackGeneratorProgress, this);
cmGlobalGenerator gg(&cm); cmGlobalGenerator gg(&cm);
cmsys::auto_ptr<cmMakefile> mf(
new cmMakefile(&gg, cm.GetCurrentSnapshot()));
cmsys::auto_ptr<cmLocalGenerator> lg( cmsys::auto_ptr<cmLocalGenerator> lg(
gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); gg.CreateLocalGenerator(mf.get()));
cmMakefile *mf = lg->GetMakefile();
std::string realInstallDirectory = tempInstallDirectory; std::string realInstallDirectory = tempInstallDirectory;
if ( !installSubDirectory.empty() && installSubDirectory != "/" ) if ( !installSubDirectory.empty() && installSubDirectory != "/" )
{ {

View File

@ -202,9 +202,10 @@ int main (int argc, char const* const* argv)
cminst.SetHomeOutputDirectory(""); cminst.SetHomeOutputDirectory("");
cminst.GetState()->RemoveUnscriptableCommands(); cminst.GetState()->RemoveUnscriptableCommands();
cmGlobalGenerator cmgg(&cminst); cmGlobalGenerator cmgg(&cminst);
cmsys::auto_ptr<cmMakefile> globalMF(
new cmMakefile(&cmgg, cminst.GetCurrentSnapshot()));
cmsys::auto_ptr<cmLocalGenerator> cmlg( cmsys::auto_ptr<cmLocalGenerator> cmlg(
cmgg.CreateLocalGenerator(cminst.GetCurrentSnapshot())); cmgg.CreateLocalGenerator(globalMF.get()));
cmMakefile* globalMF = cmlg->GetMakefile();
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0"); globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0");
#endif #endif
@ -358,8 +359,8 @@ int main (int argc, char const* const* argv)
++it ) ++it )
{ {
const char* gen = it->c_str(); const char* gen = it->c_str();
cmMakefile::ScopePushPop raii(globalMF); cmMakefile::ScopePushPop raii(globalMF.get());
cmMakefile* mf = globalMF; cmMakefile* mf = globalMF.get();
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
"Specified generator: " << gen << std::endl); "Specified generator: " << gen << std::endl);
if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") ) if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") )

View File

@ -738,9 +738,9 @@ void cmCTestLaunch::LoadConfig()
cm.SetHomeDirectory(""); cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory(""); cm.SetHomeOutputDirectory("");
cmGlobalGenerator gg(&cm); cmGlobalGenerator gg(&cm);
cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
cmsys::auto_ptr<cmLocalGenerator> lg( cmsys::auto_ptr<cmLocalGenerator> lg(
gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); gg.CreateLocalGenerator(mf.get()));
cmMakefile* mf = lg->GetMakefile();
std::string fname = this->LogDir; std::string fname = this->LogDir;
fname += "CTestLaunchConfig.cmake"; fname += "CTestLaunchConfig.cmake";
if(cmSystemTools::FileExists(fname.c_str()) && if(cmSystemTools::FileExists(fname.c_str()) &&

View File

@ -125,6 +125,7 @@ void cmCTestScriptHandler::Initialize()
// what time in seconds did this script start running // what time in seconds did this script start running
this->ScriptStartTime = 0; this->ScriptStartTime = 0;
delete this->Makefile;
this->Makefile = 0; this->Makefile = 0;
delete this->LocalGenerator; delete this->LocalGenerator;
@ -139,8 +140,7 @@ void cmCTestScriptHandler::Initialize()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
cmCTestScriptHandler::~cmCTestScriptHandler() cmCTestScriptHandler::~cmCTestScriptHandler()
{ {
// local generator owns the makefile delete this->Makefile;
this->Makefile = 0;
delete this->LocalGenerator; delete this->LocalGenerator;
delete this->GlobalGenerator; delete this->GlobalGenerator;
delete this->CMake; delete this->CMake;
@ -317,6 +317,7 @@ void cmCTestScriptHandler::CreateCMake()
delete this->CMake; delete this->CMake;
delete this->GlobalGenerator; delete this->GlobalGenerator;
delete this->LocalGenerator; delete this->LocalGenerator;
delete this->Makefile;
} }
this->CMake = new cmake; this->CMake = new cmake;
this->CMake->SetHomeDirectory(""); this->CMake->SetHomeDirectory("");
@ -325,8 +326,9 @@ void cmCTestScriptHandler::CreateCMake()
this->GlobalGenerator = new cmGlobalGenerator(this->CMake); this->GlobalGenerator = new cmGlobalGenerator(this->CMake);
cmState::Snapshot snapshot = this->CMake->GetCurrentSnapshot(); cmState::Snapshot snapshot = this->CMake->GetCurrentSnapshot();
this->LocalGenerator = this->GlobalGenerator->CreateLocalGenerator(snapshot); this->Makefile = new cmMakefile(this->GlobalGenerator, snapshot);
this->Makefile = this->LocalGenerator->GetMakefile(); this->LocalGenerator =
this->GlobalGenerator->CreateLocalGenerator(this->Makefile);
this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest); this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest);

View File

@ -1592,9 +1592,9 @@ void cmCTestTestHandler::GetListOfTests()
cm.SetHomeDirectory(""); cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory(""); cm.SetHomeOutputDirectory("");
cmGlobalGenerator gg(&cm); cmGlobalGenerator gg(&cm);
cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
cmsys::auto_ptr<cmLocalGenerator> lg( cmsys::auto_ptr<cmLocalGenerator> lg(
gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); gg.CreateLocalGenerator(mf.get()));
cmMakefile *mf = lg->GetMakefile();
mf->AddDefinition("CTEST_CONFIGURATION_TYPE", mf->AddDefinition("CTEST_CONFIGURATION_TYPE",
this->CTest->GetConfigType().c_str()); this->CTest->GetConfigType().c_str());

View File

@ -520,10 +520,10 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
cm.SetHomeDirectory(""); cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory(""); cm.SetHomeOutputDirectory("");
cmGlobalGenerator gg(&cm); cmGlobalGenerator gg(&cm);
cmsys::auto_ptr<cmLocalGenerator> lg( cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator(mf.get()));
cmMakefile *mf = lg->GetMakefile(); if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(),
if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), mf) ) mf.get()) )
{ {
cmCTestOptionalLog(this, DEBUG, cmCTestOptionalLog(this, DEBUG,
"Cannot find custom configuration file tree" << std::endl, quiet); "Cannot find custom configuration file tree" << std::endl, quiet);

View File

@ -44,10 +44,10 @@ void cmGlobalBorlandMakefileGenerator
///! Create a local generator appropriate to this Global Generator ///! Create a local generator appropriate to this Global Generator
cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator( cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator(
cmState::Snapshot snapshot) cmMakefile *mf)
{ {
cmLocalUnixMakefileGenerator3* lg = cmLocalUnixMakefileGenerator3* lg =
new cmLocalUnixMakefileGenerator3(this, snapshot); new cmLocalUnixMakefileGenerator3(this, mf);
lg->SetMakefileVariableSize(32); lg->SetMakefileVariableSize(32);
lg->SetMakeCommandEscapeTargetTwice(true); lg->SetMakeCommandEscapeTargetTwice(true);
lg->SetBorlandMakeCurlyHack(true); lg->SetBorlandMakeCurlyHack(true);

View File

@ -36,7 +36,7 @@ public:
static void GetDocumentation(cmDocumentationEntry& entry); static void GetDocumentation(cmDocumentationEntry& entry);
///! Create a local generator appropriate to this Global Generator ///! Create a local generator appropriate to this Global Generator
virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
/** /**
* Try to determine system information such as shared library * Try to determine system information such as shared library

View File

@ -1127,10 +1127,10 @@ void cmGlobalGenerator::Configure()
this->FirstTimeProgress = 0.0f; this->FirstTimeProgress = 0.0f;
this->ClearGeneratorMembers(); this->ClearGeneratorMembers();
// start with this directory cmMakefile* dirMf =
cmLocalGenerator *lg = this->CreateLocalGenerator( new cmMakefile(this, this->GetCMakeInstance()->GetCurrentSnapshot());
this->GetCMakeInstance()->GetCurrentSnapshot()); this->Makefiles.push_back(dirMf);
this->Makefiles.push_back(lg->GetMakefile()); cmLocalGenerator *lg = this->CreateLocalGenerator(dirMf);
this->LocalGenerators.push_back(lg); this->LocalGenerators.push_back(lg);
// set the Start directories // set the Start directories
@ -1601,6 +1601,7 @@ void cmGlobalGenerator::ClearGeneratorMembers()
cmDeleteAll(this->BuildExportSets); cmDeleteAll(this->BuildExportSets);
this->BuildExportSets.clear(); this->BuildExportSets.clear();
cmDeleteAll(this->Makefiles);
this->Makefiles.clear(); this->Makefiles.clear();
cmDeleteAll(this->LocalGenerators); cmDeleteAll(this->LocalGenerators);
@ -1987,9 +1988,9 @@ void cmGlobalGenerator::EnableInstallTarget()
} }
cmLocalGenerator* cmLocalGenerator*
cmGlobalGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) cmGlobalGenerator::CreateLocalGenerator(cmMakefile* mf)
{ {
return new cmLocalGenerator(this, snapshot); return new cmLocalGenerator(this, mf);
} }
void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen, void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen,

View File

@ -57,7 +57,7 @@ public:
virtual ~cmGlobalGenerator(); virtual ~cmGlobalGenerator();
virtual cmLocalGenerator* virtual cmLocalGenerator*
CreateLocalGenerator(cmState::Snapshot snapshot = cmState::Snapshot()); CreateLocalGenerator(cmMakefile* mf);
///! Get the name for this generator ///! Get the name for this generator
virtual std::string GetName() const { return "Generic"; } virtual std::string GetName() const { return "Generic"; }

View File

@ -33,9 +33,9 @@ cmGlobalGhsMultiGenerator::~cmGlobalGhsMultiGenerator()
} }
cmLocalGenerator * cmLocalGenerator *
cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmMakefile* mf)
{ {
return new cmLocalGhsMultiGenerator(this, snapshot); return new cmLocalGhsMultiGenerator(this, mf);
} }
void cmGlobalGhsMultiGenerator::GetDocumentation(cmDocumentationEntry &entry) void cmGlobalGhsMultiGenerator::GetDocumentation(cmDocumentationEntry &entry)

View File

@ -31,7 +31,7 @@ public:
{ return new cmGlobalGeneratorSimpleFactory<cmGlobalGhsMultiGenerator>(); } { return new cmGlobalGeneratorSimpleFactory<cmGlobalGhsMultiGenerator>(); }
///! create the correct local generator ///! create the correct local generator
virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
/// @return the name of this generator. /// @return the name of this generator.
static std::string GetActualName() { return "Green Hills MULTI"; } static std::string GetActualName() { return "Green Hills MULTI"; }

View File

@ -528,9 +528,9 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator(cmake* cm)
// Virtual public methods. // Virtual public methods.
cmLocalGenerator* cmLocalGenerator*
cmGlobalNinjaGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) cmGlobalNinjaGenerator::CreateLocalGenerator(cmMakefile* mf)
{ {
return new cmLocalNinjaGenerator(this, snapshot); return new cmLocalNinjaGenerator(this, mf);
} }
void cmGlobalNinjaGenerator void cmGlobalNinjaGenerator

View File

@ -167,7 +167,7 @@ public:
virtual ~cmGlobalNinjaGenerator() { } virtual ~cmGlobalNinjaGenerator() { }
virtual cmLocalGenerator* CreateLocalGenerator(cmState::Snapshot snapshot); virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf);
virtual std::string GetName() const { virtual std::string GetName() const {
return cmGlobalNinjaGenerator::GetActualName(); } return cmGlobalNinjaGenerator::GetActualName(); }

View File

@ -60,9 +60,9 @@ void cmGlobalUnixMakefileGenerator3
///! Create a local generator appropriate to this Global Generator ///! Create a local generator appropriate to this Global Generator
cmLocalGenerator* cmGlobalUnixMakefileGenerator3::CreateLocalGenerator( cmLocalGenerator* cmGlobalUnixMakefileGenerator3::CreateLocalGenerator(
cmState::Snapshot snapshot) cmMakefile* mf)
{ {
return new cmLocalUnixMakefileGenerator3(this, snapshot); return new cmLocalUnixMakefileGenerator3(this, mf);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -577,17 +577,20 @@ void cmGlobalUnixMakefileGenerator3
makeOptions.begin(), makeOptions.end()); makeOptions.begin(), makeOptions.end());
if (!targetName.empty()) if (!targetName.empty())
{ {
cmMakefile* mf;
cmLocalUnixMakefileGenerator3 *lg; cmLocalUnixMakefileGenerator3 *lg;
if (!this->LocalGenerators.empty()) if (!this->LocalGenerators.empty())
{ {
lg = static_cast<cmLocalUnixMakefileGenerator3 *> lg = static_cast<cmLocalUnixMakefileGenerator3 *>
(this->LocalGenerators[0]); (this->LocalGenerators[0]);
mf = lg->GetMakefile();
} }
else else
{ {
cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot(); cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot();
mf = new cmMakefile(this, snapshot);
lg = static_cast<cmLocalUnixMakefileGenerator3 *> lg = static_cast<cmLocalUnixMakefileGenerator3 *>
(this->CreateLocalGenerator(snapshot)); (this->CreateLocalGenerator(mf));
// set the Start directories // set the Start directories
lg->GetMakefile()->SetCurrentSourceDirectory lg->GetMakefile()->SetCurrentSourceDirectory
(this->CMakeInstance->GetHomeDirectory()); (this->CMakeInstance->GetHomeDirectory());
@ -606,6 +609,7 @@ void cmGlobalUnixMakefileGenerator3
if (this->LocalGenerators.empty()) if (this->LocalGenerators.empty())
{ {
delete lg; delete lg;
delete mf;
} }
} }
} }

View File

@ -67,8 +67,7 @@ public:
/** Get the documentation entry for this generator. */ /** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry); static void GetDocumentation(cmDocumentationEntry& entry);
///! Create a local generator appropriate to this Global Generator3 virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot);
/** /**
* Try to determine system information such as shared library * Try to determine system information such as shared library

View File

@ -307,9 +307,9 @@ void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout)
///! Create a local generator appropriate to this Global Generator ///! Create a local generator appropriate to this Global Generator
cmLocalGenerator* cmGlobalVisualStudio10Generator::CreateLocalGenerator( cmLocalGenerator* cmGlobalVisualStudio10Generator::CreateLocalGenerator(
cmState::Snapshot snapshot) cmMakefile* mf)
{ {
return new cmLocalVisualStudio10Generator(this, snapshot); return new cmLocalVisualStudio10Generator(this, mf);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -48,7 +48,7 @@ public:
virtual bool Compute(); virtual bool Compute();
///! create the correct local generator ///! create the correct local generator
virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
/** /**
* Try to determine system information such as shared library * Try to determine system information such as shared library

View File

@ -173,10 +173,9 @@ cmGlobalVisualStudio6Generator::GenerateBuildCommand(
///! Create a local generator appropriate to this Global Generator ///! Create a local generator appropriate to this Global Generator
cmLocalGenerator * cmLocalGenerator *
cmGlobalVisualStudio6Generator::CreateLocalGenerator( cmGlobalVisualStudio6Generator::CreateLocalGenerator(cmMakefile* mf)
cmState::Snapshot snapshot)
{ {
return new cmLocalVisualStudio6Generator(this, snapshot); return new cmLocalVisualStudio6Generator(this, mf);
} }

View File

@ -39,7 +39,7 @@ public:
static void GetDocumentation(cmDocumentationEntry& entry); static void GetDocumentation(cmDocumentationEntry& entry);
///! Create a local generator appropriate to this Global Generator ///! Create a local generator appropriate to this Global Generator
virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
/** /**
* Try to determine system information such as shared library * Try to determine system information such as shared library

View File

@ -280,10 +280,10 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand(
///! Create a local generator appropriate to this Global Generator ///! Create a local generator appropriate to this Global Generator
cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator( cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator(
cmState::Snapshot snapshot) cmMakefile* mf)
{ {
cmLocalVisualStudio7Generator *lg = cmLocalVisualStudio7Generator *lg =
new cmLocalVisualStudio7Generator(this, snapshot); new cmLocalVisualStudio7Generator(this, mf);
return lg; return lg;
} }

View File

@ -43,7 +43,7 @@ public:
std::string const& GetPlatformName() const; std::string const& GetPlatformName() const;
///! Create a local generator appropriate to this Global Generator ///! Create a local generator appropriate to this Global Generator
virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
virtual bool SetSystemName(std::string const& s, cmMakefile* mf); virtual bool SetSystemName(std::string const& s, cmMakefile* mf);

View File

@ -371,9 +371,9 @@ cmGlobalXCodeGenerator::GenerateBuildCommand(
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
///! Create a local generator appropriate to this Global Generator ///! Create a local generator appropriate to this Global Generator
cmLocalGenerator * cmLocalGenerator *
cmGlobalXCodeGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) cmGlobalXCodeGenerator::CreateLocalGenerator(cmMakefile* mf)
{ {
return new cmLocalXCodeGenerator(this, snapshot); return new cmLocalXCodeGenerator(this, mf);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -41,7 +41,7 @@ public:
static void GetDocumentation(cmDocumentationEntry& entry); static void GetDocumentation(cmDocumentationEntry& entry);
///! Create a local generator appropriate to this Global Generator ///! Create a local generator appropriate to this Global Generator
virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile *mf);
/** /**
* Try to determine system information such as shared library * Try to determine system information such as shared library

View File

@ -68,9 +68,9 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
cm.SetHomeDirectory(""); cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory(""); cm.SetHomeOutputDirectory("");
cmGlobalGenerator ggi(&cm); cmGlobalGenerator ggi(&cm);
cmsys::auto_ptr<cmLocalGenerator> lg( cmsys::auto_ptr<cmMakefile> mf(
ggi.CreateLocalGenerator(cm.GetCurrentSnapshot())); new cmMakefile(&ggi, cm.GetCurrentSnapshot()));
cmMakefile *mf = lg->GetMakefile(); cmsys::auto_ptr<cmLocalGenerator> lg(ggi.CreateLocalGenerator(mf.get()));
const char* inFileName = settingsFileName; const char* inFileName = settingsFileName;

View File

@ -14,8 +14,8 @@
#include "cmMakefile.h" #include "cmMakefile.h"
cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg, cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg,
cmState::Snapshot snapshot): cmMakefile* mf):
cmLocalGenerator(gg, snapshot) cmLocalGenerator(gg, mf)
{ {
} }

View File

@ -22,8 +22,7 @@ class cmCommonTargetGenerator;
class cmLocalCommonGenerator: public cmLocalGenerator class cmLocalCommonGenerator: public cmLocalGenerator
{ {
public: public:
cmLocalCommonGenerator(cmGlobalGenerator* gg, cmLocalCommonGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
cmState::Snapshot snapshot);
~cmLocalCommonGenerator(); ~cmLocalCommonGenerator();
std::string const& GetConfigName() { return this->ConfigName; } std::string const& GetConfigName() { return this->ConfigName; }

View File

@ -43,13 +43,13 @@
#endif #endif
cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg,
cmState::Snapshot snapshot) cmMakefile* makefile)
: cmOutputConverter(snapshot), StateSnapshot(snapshot) : cmOutputConverter(makefile->GetStateSnapshot()),
StateSnapshot(makefile->GetStateSnapshot())
{ {
assert(snapshot.IsValid());
this->GlobalGenerator = gg; this->GlobalGenerator = gg;
this->Makefile = new cmMakefile(gg, snapshot); this->Makefile = makefile;
this->EmitUniversalBinaryFlags = true; this->EmitUniversalBinaryFlags = true;
this->BackwardsCompatibility = 0; this->BackwardsCompatibility = 0;
@ -58,7 +58,6 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg,
cmLocalGenerator::~cmLocalGenerator() cmLocalGenerator::~cmLocalGenerator()
{ {
delete this->Makefile;
} }
void cmLocalGenerator::IssueMessage(cmake::MessageType t, void cmLocalGenerator::IssueMessage(cmake::MessageType t,

View File

@ -36,7 +36,7 @@ class cmCustomCommandGenerator;
class cmLocalGenerator : public cmOutputConverter class cmLocalGenerator : public cmOutputConverter
{ {
public: public:
cmLocalGenerator(cmGlobalGenerator* gg, cmState::Snapshot snapshot); cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile);
virtual ~cmLocalGenerator(); virtual ~cmLocalGenerator();
/** /**

View File

@ -17,8 +17,8 @@
#include "cmGeneratedFileStream.h" #include "cmGeneratedFileStream.h"
cmLocalGhsMultiGenerator::cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, cmLocalGhsMultiGenerator::cmLocalGhsMultiGenerator(cmGlobalGenerator* gg,
cmState::Snapshot snapshot) cmMakefile* mf)
: cmLocalGenerator(gg, snapshot) : cmLocalGenerator(gg, mf)
{ {
} }

View File

@ -25,8 +25,7 @@ class cmGeneratedFileStream;
class cmLocalGhsMultiGenerator : public cmLocalGenerator class cmLocalGhsMultiGenerator : public cmLocalGenerator
{ {
public: public:
cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
cmState::Snapshot snapshot);
virtual ~cmLocalGhsMultiGenerator(); virtual ~cmLocalGhsMultiGenerator();

View File

@ -23,8 +23,8 @@
#include <assert.h> #include <assert.h>
cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg,
cmState::Snapshot snapshot) cmMakefile* mf)
: cmLocalCommonGenerator(gg, snapshot) : cmLocalCommonGenerator(gg, mf)
, HomeRelativeOutputPath("") , HomeRelativeOutputPath("")
{ {
this->TargetImplib = "$TARGET_IMPLIB"; this->TargetImplib = "$TARGET_IMPLIB";

View File

@ -31,8 +31,7 @@ class cmake;
class cmLocalNinjaGenerator : public cmLocalCommonGenerator class cmLocalNinjaGenerator : public cmLocalCommonGenerator
{ {
public: public:
cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
cmState::Snapshot snapshot);
virtual ~cmLocalNinjaGenerator(); virtual ~cmLocalNinjaGenerator();

View File

@ -80,9 +80,8 @@ static std::string cmSplitExtension(std::string const& in, std::string& base)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmLocalUnixMakefileGenerator3:: cmLocalUnixMakefileGenerator3::
cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmMakefile* mf)
cmState::Snapshot snapshot) : cmLocalCommonGenerator(gg, mf)
: cmLocalCommonGenerator(gg, snapshot)
{ {
this->MakefileVariableSize = 0; this->MakefileVariableSize = 0;
this->ColorMakefile = false; this->ColorMakefile = false;

View File

@ -34,8 +34,7 @@ class cmSourceFile;
class cmLocalUnixMakefileGenerator3 : public cmLocalCommonGenerator class cmLocalUnixMakefileGenerator3 : public cmLocalCommonGenerator
{ {
public: public:
cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmMakefile* mf);
cmState::Snapshot snapshot);
virtual ~cmLocalUnixMakefileGenerator3(); virtual ~cmLocalUnixMakefileGenerator3();
virtual void ComputeHomeRelativeOutputPath(); virtual void ComputeHomeRelativeOutputPath();

View File

@ -62,9 +62,8 @@ class cmVS10XMLParser : public cmXMLParser
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmLocalVisualStudio10Generator cmLocalVisualStudio10Generator
::cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, ::cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, cmMakefile* mf):
cmState::Snapshot snapshot): cmLocalVisualStudio7Generator(gg, mf)
cmLocalVisualStudio7Generator(gg, snapshot)
{ {
} }

View File

@ -25,8 +25,7 @@ class cmLocalVisualStudio10Generator : public cmLocalVisualStudio7Generator
{ {
public: public:
///! Set cache only and recurse to false by default. ///! Set cache only and recurse to false by default.
cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, cmMakefile* mf);
cmState::Snapshot snapshot);
virtual ~cmLocalVisualStudio10Generator(); virtual ~cmLocalVisualStudio10Generator();

View File

@ -24,9 +24,8 @@
#include <cmsys/FStream.hxx> #include <cmsys/FStream.hxx>
cmLocalVisualStudio6Generator cmLocalVisualStudio6Generator
::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, ::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmMakefile* mf):
cmState::Snapshot snapshot): cmLocalVisualStudioGenerator(gg, mf)
cmLocalVisualStudioGenerator(gg, snapshot)
{ {
} }

View File

@ -29,8 +29,7 @@ class cmLocalVisualStudio6Generator : public cmLocalVisualStudioGenerator
{ {
public: public:
///! Set cache only and recurse to false by default. ///! Set cache only and recurse to false by default.
cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmMakefile* mf);
cmState::Snapshot snapshot);
virtual ~cmLocalVisualStudio6Generator(); virtual ~cmLocalVisualStudio6Generator();

View File

@ -53,9 +53,8 @@ static void cmConvertToWindowsSlash(std::string& s)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmLocalVisualStudio7Generator cmLocalVisualStudio7Generator
::cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, ::cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmMakefile* mf):
cmState::Snapshot snapshot): cmLocalVisualStudioGenerator(gg, mf)
cmLocalVisualStudioGenerator(gg, snapshot)
{ {
this->Internal = new cmLocalVisualStudio7GeneratorInternals(this); this->Internal = new cmLocalVisualStudio7GeneratorInternals(this);
} }

View File

@ -35,8 +35,7 @@ class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator
{ {
public: public:
///! Set cache only and recurse to false by default. ///! Set cache only and recurse to false by default.
cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmMakefile* mf);
cmState::Snapshot snapshot);
virtual ~cmLocalVisualStudio7Generator(); virtual ~cmLocalVisualStudio7Generator();

View File

@ -19,9 +19,8 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmLocalVisualStudioGenerator cmLocalVisualStudioGenerator
::cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, ::cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, cmMakefile* mf)
cmState::Snapshot snapshot) : cmLocalGenerator(gg, mf)
: cmLocalGenerator(gg, snapshot)
{ {
} }

View File

@ -31,8 +31,7 @@ class cmCustomCommandGenerator;
class cmLocalVisualStudioGenerator : public cmLocalGenerator class cmLocalVisualStudioGenerator : public cmLocalGenerator
{ {
public: public:
cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
cmState::Snapshot snapshot);
virtual ~cmLocalVisualStudioGenerator(); virtual ~cmLocalVisualStudioGenerator();
/** Construct a script from the given list of command lines. */ /** Construct a script from the given list of command lines. */

View File

@ -16,8 +16,8 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmLocalXCodeGenerator::cmLocalXCodeGenerator(cmGlobalGenerator* gg, cmLocalXCodeGenerator::cmLocalXCodeGenerator(cmGlobalGenerator* gg,
cmState::Snapshot snapshot) cmMakefile* mf)
: cmLocalGenerator(gg, snapshot) : cmLocalGenerator(gg, mf)
{ {
// the global generator does this, so do not // the global generator does this, so do not
// put these flags into the language flags // put these flags into the language flags

View File

@ -25,7 +25,7 @@ class cmLocalXCodeGenerator : public cmLocalGenerator
public: public:
///! Set cache only and recurse to false by default. ///! Set cache only and recurse to false by default.
cmLocalXCodeGenerator(cmGlobalGenerator* gg, cmLocalXCodeGenerator(cmGlobalGenerator* gg,
cmState::Snapshot snapshot); cmMakefile* mf);
virtual ~cmLocalXCodeGenerator(); virtual ~cmLocalXCodeGenerator();
virtual std::string GetTargetDirectory(cmTarget const& target) const; virtual std::string GetTargetDirectory(cmTarget const& target) const;

View File

@ -16,7 +16,6 @@
#include "cmSourceFileLocation.h" #include "cmSourceFileLocation.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmGlobalGenerator.h" #include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h"
#include "cmCommands.h" #include "cmCommands.h"
#include "cmState.h" #include "cmState.h"
#include "cmOutputConverter.h" #include "cmOutputConverter.h"
@ -1754,14 +1753,14 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
this->ContextStack.back()->Name, this->ContextStack.back()->Name,
this->ContextStack.back()->Line); this->ContextStack.back()->Line);
cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot);
this->GetGlobalGenerator()->AddMakefile(subMf);
// create a new local generator and set its parent // create a new local generator and set its parent
cmLocalGenerator *lg2 = this->GetGlobalGenerator() cmLocalGenerator *lg2 = this->GetGlobalGenerator()
->CreateLocalGenerator(newSnapshot); ->CreateLocalGenerator(subMf);
this->GetGlobalGenerator()->AddMakefile(lg2->GetMakefile());
this->GetGlobalGenerator()->AddLocalGenerator(lg2); this->GetGlobalGenerator()->AddLocalGenerator(lg2);
cmMakefile* subMf = lg2->GetMakefile();
// set the subdirs start dirs // set the subdirs start dirs
subMf->SetCurrentSourceDirectory(srcPath); subMf->SetCurrentSourceDirectory(srcPath);
subMf->SetCurrentBinaryDirectory(binPath); subMf->SetCurrentBinaryDirectory(binPath);

View File

@ -1218,7 +1218,8 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
cmGlobalGenerator gg(&cm); cmGlobalGenerator gg(&cm);
cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); cmState::Snapshot snapshot = cm.GetCurrentSnapshot();
cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator(snapshot)); cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, snapshot));
cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator(mf.get()));
lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory); lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory);
lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory); lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory);
gg.SetCurrentMakefile(lg->GetMakefile()); gg.SetCurrentMakefile(lg->GetMakefile());

View File

@ -430,7 +430,8 @@ void cmake::ReadListFile(const std::vector<std::string>& args,
this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory()); this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory()); this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory());
cmState::Snapshot snapshot = this->GetCurrentSnapshot(); cmState::Snapshot snapshot = this->GetCurrentSnapshot();
cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator(snapshot)); cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(gg, snapshot));
cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator(mf.get()));
lg->GetMakefile()->SetCurrentBinaryDirectory lg->GetMakefile()->SetCurrentBinaryDirectory
(cmSystemTools::GetCurrentWorkingDirectory()); (cmSystemTools::GetCurrentWorkingDirectory());
lg->GetMakefile()->SetCurrentSourceDirectory lg->GetMakefile()->SetCurrentSourceDirectory
@ -472,8 +473,8 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
cmState::Snapshot snapshot = this->GetCurrentSnapshot(); cmState::Snapshot snapshot = this->GetCurrentSnapshot();
// read in the list file to fill the cache // read in the list file to fill the cache
cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator(snapshot)); cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(gg, snapshot));
cmMakefile* mf = lg->GetMakefile(); cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator(mf.get()));
mf->SetCurrentBinaryDirectory mf->SetCurrentBinaryDirectory
(cmSystemTools::GetCurrentWorkingDirectory()); (cmSystemTools::GetCurrentWorkingDirectory());
mf->SetCurrentSourceDirectory mf->SetCurrentSourceDirectory
@ -2061,9 +2062,8 @@ int cmake::CheckBuildSystem()
cm.SetHomeDirectory(""); cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory(""); cm.SetHomeOutputDirectory("");
cmGlobalGenerator gg(&cm); cmGlobalGenerator gg(&cm);
cmsys::auto_ptr<cmLocalGenerator> lg( cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator(mf.get()));
cmMakefile* mf = lg->GetMakefile();
if(!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) || if(!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) ||
cmSystemTools::GetErrorOccuredFlag()) cmSystemTools::GetErrorOccuredFlag())
{ {
@ -2092,9 +2092,11 @@ int cmake::CheckBuildSystem()
ggd(this->CreateGlobalGenerator(genName)); ggd(this->CreateGlobalGenerator(genName));
if(ggd.get()) if(ggd.get())
{ {
cmsys::auto_ptr<cmMakefile> mfd(new cmMakefile(ggd.get(),
cm.GetCurrentSnapshot()));
cmsys::auto_ptr<cmLocalGenerator> lgd( cmsys::auto_ptr<cmLocalGenerator> lgd(
ggd->CreateLocalGenerator(cm.GetCurrentSnapshot())); ggd->CreateLocalGenerator(mfd.get()));
lgd->ClearDependencies(mf, verbose); lgd->ClearDependencies(mfd.get(), verbose);
} }
} }

View File

@ -769,8 +769,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
{ {
cm.SetGlobalGenerator(ggd); cm.SetGlobalGenerator(ggd);
cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); cmState::Snapshot snapshot = cm.GetCurrentSnapshot();
cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(ggd, snapshot));
cmsys::auto_ptr<cmLocalGenerator> lgd( cmsys::auto_ptr<cmLocalGenerator> lgd(
ggd->CreateLocalGenerator(snapshot)); ggd->CreateLocalGenerator(mf.get()));
lgd->GetMakefile()->SetCurrentSourceDirectory(startDir); lgd->GetMakefile()->SetCurrentSourceDirectory(startDir);
lgd->GetMakefile()->SetCurrentBinaryDirectory(startOutDir); lgd->GetMakefile()->SetCurrentBinaryDirectory(startOutDir);