Merge topic 'try_compile-RemoveFile'

097294e Fix try_compile RemoveFile anti-virus loop (#11503)
This commit is contained in:
Brad King 2010-12-16 14:00:28 -05:00 committed by CMake Topic Stage
commit 72ebd4ee12
1 changed files with 11 additions and 21 deletions

View File

@ -397,26 +397,17 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir)
} }
else else
{ {
if(!cmSystemTools::RemoveFile(fullPath.c_str())) // Sometimes anti-virus software hangs on to new files so we
{ // cannot delete them immediately. Try a few times.
bool removed = false; int tries = 5;
int numAttempts = 0; while(!cmSystemTools::RemoveFile(fullPath.c_str()) &&
// sometimes anti-virus software hangs on to --tries && cmSystemTools::FileExists(fullPath.c_str()))
// new files and we can not delete them, so try
// 5 times with .5 second delay between tries.
while(!removed && numAttempts < 5)
{ {
cmSystemTools::Delay(500); cmSystemTools::Delay(500);
if(cmSystemTools::RemoveFile(fullPath.c_str()))
{
removed = true;
} }
numAttempts++; if(tries == 0)
}
if(!removed)
{ {
std::string m = "Remove failed on file: "; std::string m = "Remove failed on file: " + fullPath;
m += fullPath;
cmSystemTools::ReportLastSystemError(m.c_str()); cmSystemTools::ReportLastSystemError(m.c_str());
} }
} }
@ -424,7 +415,6 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir)
} }
} }
} }
}
void cmCoreTryCompile::FindOutputFile(const char* targetName) void cmCoreTryCompile::FindOutputFile(const char* targetName)
{ {