summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmCTestBuildCommand.cxx
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2005-05-08 17:48:09 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2005-05-08 17:48:09 (GMT)
commit0842958977ce9037cf597871df6baf72736c7973 (patch)
tree73e44dace3eb4f7420bff2c4fef2cc0a88fde089 /Source/CTest/cmCTestBuildCommand.cxx
parent4e49c3bf6e6782f961153732a8fe1258fc7e7f2f (diff)
downloadCMake-0842958977ce9037cf597871df6baf72736c7973.zip
CMake-0842958977ce9037cf597871df6baf72736c7973.tar.gz
CMake-0842958977ce9037cf597871df6baf72736c7973.tar.bz2
ENH: Remove memory leak and remember global generator for next time
Diffstat (limited to 'Source/CTest/cmCTestBuildCommand.cxx')
-rw-r--r--Source/CTest/cmCTestBuildCommand.cxx41
1 files changed, 35 insertions, 6 deletions
diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx
index d8f1ef7..4812152 100644
--- a/Source/CTest/cmCTestBuildCommand.cxx
+++ b/Source/CTest/cmCTestBuildCommand.cxx
@@ -21,6 +21,24 @@
#include "cmake.h"
#include "cmGlobalGenerator.h"
+
+//----------------------------------------------------------------------------
+cmCTestBuildCommand::cmCTestBuildCommand()
+{
+ m_GlobalGenerator = 0;
+}
+
+//----------------------------------------------------------------------------
+cmCTestBuildCommand::~cmCTestBuildCommand()
+{
+ if ( m_GlobalGenerator )
+ {
+ delete m_GlobalGenerator;
+ m_GlobalGenerator = 0;
+ }
+}
+
+//----------------------------------------------------------------------------
bool cmCTestBuildCommand::InitialPass(
std::vector<std::string> const& args)
{
@@ -97,13 +115,24 @@ bool cmCTestBuildCommand::InitialPass(
{
cmakeBuildConfiguration = "Release";
}
- cmGlobalGenerator* gen =
- m_Makefile->GetCMakeInstance()->CreateGlobalGenerator(cmakeGeneratorName);
- gen->FindMakeProgram(m_Makefile);
+ if ( m_GlobalGenerator )
+ {
+ if ( strcmp(m_GlobalGenerator->GetName(), cmakeGeneratorName) != 0 )
+ {
+ delete m_GlobalGenerator;
+ m_GlobalGenerator = 0;
+ }
+ }
+ if ( !m_GlobalGenerator )
+ {
+ m_GlobalGenerator =
+ m_Makefile->GetCMakeInstance()->CreateGlobalGenerator(cmakeGeneratorName);
+ }
+ m_GlobalGenerator->FindMakeProgram(m_Makefile);
const char* cmakeMakeProgram = m_Makefile->GetDefinition("CMAKE_MAKE_PROGRAM");
- std::string buildCommand = gen->GenerateBuildCommand(cmakeMakeProgram, cmakeProjectName,
- 0, cmakeBuildConfiguration, true);
-
+ std::string buildCommand
+ = m_GlobalGenerator->GenerateBuildCommand(cmakeMakeProgram, cmakeProjectName,
+ 0, cmakeBuildConfiguration, true);
m_CTest->SetCTestConfiguration("MakeCommand", buildCommand.c_str());
}
else