summaryrefslogtreecommitdiffstats
path: root/Source/cmCacheManager.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-02-18 14:51:40 (GMT)
committerBrad King <brad.king@kitware.com>2013-02-18 14:58:34 (GMT)
commit1df09e57732501454ac2bee900d2aad963a84969 (patch)
treebbd22af46b619f4b0160d8457c8b767791c8b17c /Source/cmCacheManager.cxx
parenta7742140ad1a88e354037ea391c0e773f147ebd2 (diff)
downloadCMake-1df09e57732501454ac2bee900d2aad963a84969.zip
CMake-1df09e57732501454ac2bee900d2aad963a84969.tar.gz
CMake-1df09e57732501454ac2bee900d2aad963a84969.tar.bz2
Delete entire CMakeFiles directory when deleting CMakeCache.txt (#13756)
Since commit e015df7d (...delete CMakeFiles directory when cache is deleted, 2006-02-20) we deleted the files in the CMakeFiles directory when deleting CMakeCache.txt in order to reset the build tree to a fresh state. This allowed commit fd33bf93 (fix for bug 6102, allow users to change the compiler, 2007-12-13) to delete CMakeCache.txt when the user changes the compiler and CMakeFiles/CMake<lang>Compiler.cmake and other platform information files would go with it to allow a fresh start. Then commit 7195aca5 (Make platform information files specific to the CMake version, 2012-08-24) moved the platform information files to a subdirectory e.g. CMakeFiles/<version>/CMake<lang>Compiler.cmake where <version> is the current CMake version. This causes the compiler change logic to fail to remove all old compiler information. Then on the next configuration CMake<lang>Compiler.cmake would set CMAKE_<lang>_COMPILER back to the old value and re-trigger the compiler change logic. This causes an infinite loop of cache deletion and compiler reset. Fix this simply by teaching cmCacheManager::DeleteCache to remove the entire CMakeFiles directory recursively whenever it removes an existing CMakeCache.txt. This fully resets the build tree to configure with a fresh compiler.
Diffstat (limited to 'Source/cmCacheManager.cxx')
-rw-r--r--Source/cmCacheManager.cxx24
1 files changed, 8 insertions, 16 deletions
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index 4231243..3d5b24b 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -584,23 +584,15 @@ bool cmCacheManager::DeleteCache(const char* path)
cmSystemTools::ConvertToUnixSlashes(cacheFile);
std::string cmakeFiles = cacheFile;
cacheFile += "/CMakeCache.txt";
- cmSystemTools::RemoveFile(cacheFile.c_str());
- // now remove the files in the CMakeFiles directory
- // this cleans up language cache files
- cmsys::Directory dir;
- cmakeFiles += cmake::GetCMakeFilesDirectory();
- dir.Load(cmakeFiles.c_str());
- for (unsigned long fileNum = 0;
- fileNum < dir.GetNumberOfFiles();
- ++fileNum)
- {
- if(!cmSystemTools::
- FileIsDirectory(dir.GetFile(fileNum)))
+ if(cmSystemTools::FileExists(cacheFile.c_str()))
+ {
+ cmSystemTools::RemoveFile(cacheFile.c_str());
+ // now remove the files in the CMakeFiles directory
+ // this cleans up language cache files
+ cmakeFiles += cmake::GetCMakeFilesDirectory();
+ if(cmSystemTools::FileIsDirectory(cmakeFiles.c_str()))
{
- std::string fullPath = cmakeFiles;
- fullPath += "/";
- fullPath += dir.GetFile(fileNum);
- cmSystemTools::RemoveFile(fullPath.c_str());
+ cmSystemTools::RemoveADirectory(cmakeFiles.c_str());
}
}
return true;