summaryrefslogtreecommitdiffstats
path: root/Source/cmCoreTryCompile.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-02-12 14:45:56 (GMT)
committerBrad King <brad.king@kitware.com>2014-02-12 14:55:41 (GMT)
commit7b1f966a6c456270004a2aec2c53057ca8efbac9 (patch)
tree9ac334c91b0a8a501ef34350bf8675cd5ce6f719 /Source/cmCoreTryCompile.cxx
parent5104f55d3f9cf2f9b2537364d1b9a5c86d2f790b (diff)
downloadCMake-7b1f966a6c456270004a2aec2c53057ca8efbac9.zip
CMake-7b1f966a6c456270004a2aec2c53057ca8efbac9.tar.gz
CMake-7b1f966a6c456270004a2aec2c53057ca8efbac9.tar.bz2
Windows: Make file delete/rename retry configurable
Several CMake operations need to replace files in rapid succession. This commonly fails on Windows due to filesystem lock behavior so we have retry loops. No matter how many times we retry or how long we delay there will inevitably be someone with an environment that needs more. Make the retry count and delay configurable in the Windows Registry keys: {HKCU,HKLM}/Software/Kitware/CMake/Config in DWORD values FilesystemRetryCount = Number of tries FilesystemRetryDelay = Delay in milliseconds between tries Leave the feature undocumented for now to see how it goes.
Diffstat (limited to 'Source/cmCoreTryCompile.cxx')
-rw-r--r--Source/cmCoreTryCompile.cxx13
1 files changed, 9 insertions, 4 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index bbdb3a1..7b52069 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -585,15 +585,20 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir)
}
else
{
+#ifdef _WIN32
// Sometimes anti-virus software hangs on to new files so we
// cannot delete them immediately. Try a few times.
- int tries = 5;
+ cmSystemTools::WindowsFileRetry retry =
+ cmSystemTools::GetWindowsFileRetry();
while(!cmSystemTools::RemoveFile(fullPath.c_str()) &&
- --tries && cmSystemTools::FileExists(fullPath.c_str()))
+ --retry.Count && cmSystemTools::FileExists(fullPath.c_str()))
{
- cmSystemTools::Delay(500);
+ cmSystemTools::Delay(retry.Delay);
}
- if(tries == 0)
+ if(retry.Count == 0)
+#else
+ if(!cmSystemTools::RemoveFile(fullPath.c_str()))
+#endif
{
std::string m = "Remove failed on file: " + fullPath;
cmSystemTools::ReportLastSystemError(m.c_str());