From c544cb43078a92c7c04ef4ebccb36310765b6487 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Thu, 21 Nov 2002 14:59:41 -0500 Subject: [PATCH] clean up entire temp directory --- Source/cmTryCompileCommand.cxx | 24 ++++++++++++++---------- Source/cmTryCompileCommand.h | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx index a2c2af8a0..44752eb8d 100644 --- a/Source/cmTryCompileCommand.cxx +++ b/Source/cmTryCompileCommand.cxx @@ -229,22 +229,19 @@ bool cmTryCompileCommand::InitialPass(std::vector const& argv) static void cmTryCompileCommandNotUsed(bool){} -void cmTryCompileCommand::CleanupFiles(const char* binDir, bool recursive) +void cmTryCompileCommand::CleanupFiles(const char* binDir) { if ( !binDir ) { return; } - cmTryCompileCommandNotUsed(recursive); -#ifdef WIN32 - if ( recursive ) + std::string bdir = binDir; + if(bdir.find("CMakeTmp") == std::string::npos) { - std::string bdir = binDir; - bdir += "/Debug"; - cmTryCompileCommand::CleanupFiles(bdir.c_str(), false); + cmSystemTools::Error("TRY_COMPILE attempt to remove -rf directory that does not contain CMakeTmp:", binDir); + return; } -#endif - + cmDirectory dir; dir.Load(binDir); size_t fileNum; @@ -256,7 +253,14 @@ void cmTryCompileCommand::CleanupFiles(const char* binDir, bool recursive) std::string fullPath = binDir; fullPath += "/"; fullPath += dir.GetFile(fileNum); - cmSystemTools::RemoveFile(fullPath.c_str()); + if(cmSystemTools::FileIsDirectory(fullPath.c_str())) + { + cmTryCompileCommand::CleanupFiles(fullPath.c_str()); + } + else + { + cmSystemTools::RemoveFile(fullPath.c_str()); + } } } } diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h index ac18d76af..dee337a47 100644 --- a/Source/cmTryCompileCommand.h +++ b/Source/cmTryCompileCommand.h @@ -68,7 +68,7 @@ public: * code. This way we do not have to rely on the timing and * dependencies of makefiles. */ - static void CleanupFiles(const char* binDir, bool recursive=true); + static void CleanupFiles(const char* binDir); /** * More documentation. */