summaryrefslogtreecommitdiff
path: root/Source/cmLocalGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-09-03 08:26:31 -0400
committerBrad King <brad.king@kitware.com>2009-09-03 08:26:31 -0400
commita6890a1673aec8e3bf6afa7daa8d738ff4d32868 (patch)
tree036ad85d69a2c9263bf71244c4ee0948f7905f4c /Source/cmLocalGenerator.cxx
parent2ea28107377b83852a9bdff83ab1bf19653600ee (diff)
downloadcmake-a6890a1673aec8e3bf6afa7daa8d738ff4d32868.tar.gz
Manage current local generator with automatic var
The cmLocalGenerator::Configure method sets its cmLocalGenerator instance as the global generator's current local generator during configuration. This commit refactors management of the current local generator to use an automatic variable. This will allow early returns from the method.
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r--Source/cmLocalGenerator.cxx27
1 files changed, 22 insertions, 5 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index cac52b2358..c051e0b56b 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -68,11 +68,30 @@ cmLocalGenerator::~cmLocalGenerator()
delete this->Makefile;
}
+//----------------------------------------------------------------------------
+class cmLocalGeneratorCurrent
+{
+ cmGlobalGenerator* GG;
+ cmLocalGenerator* LG;
+public:
+ cmLocalGeneratorCurrent(cmLocalGenerator* lg)
+ {
+ this->GG = lg->GetGlobalGenerator();
+ this->LG = this->GG->GetCurrentLocalGenerator();
+ this->GG->SetCurrentLocalGenerator(lg);
+ }
+ ~cmLocalGeneratorCurrent()
+ {
+ this->GG->SetCurrentLocalGenerator(this->LG);
+ }
+};
+
+//----------------------------------------------------------------------------
void cmLocalGenerator::Configure()
{
- cmLocalGenerator* previousLg =
- this->GetGlobalGenerator()->GetCurrentLocalGenerator();
- this->GetGlobalGenerator()->SetCurrentLocalGenerator(this);
+ // Manage the global generator's current local generator.
+ cmLocalGeneratorCurrent clg(this);
+ static_cast<void>(clg);
// make sure the CMakeFiles dir is there
std::string filesDir = this->Makefile->GetStartOutputDirectory();
@@ -141,8 +160,6 @@ void cmLocalGenerator::Configure()
}
this->Configured = true;
-
- this->GetGlobalGenerator()->SetCurrentLocalGenerator(previousLg);
}
void cmLocalGenerator::SetupPathConversions()