summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2005-08-11 17:20:23 (GMT)
committerKen Martin <ken.martin@kitware.com>2005-08-11 17:20:23 (GMT)
commit039d4b604e7b35b9f9daa4edde8f348296d5ea28 (patch)
treec3cd53290a2cef57d80831e27f3a1b1bd2eabfa7
parent8a537ce3300c2e5e36a26eeae3c93bec8d6d526e (diff)
downloadCMake-039d4b604e7b35b9f9daa4edde8f348296d5ea28.zip
CMake-039d4b604e7b35b9f9daa4edde8f348296d5ea28.tar.gz
CMake-039d4b604e7b35b9f9daa4edde8f348296d5ea28.tar.bz2
ENH: added better error checking for cases when there is a CMakeCache.txt file but it is not readable
-rw-r--r--Source/MFCDialog/CMakeSetupDialog.cpp47
-rw-r--r--Source/cmake.cxx13
2 files changed, 46 insertions, 14 deletions
diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp
index 594d060..a6ebc46 100644
--- a/Source/MFCDialog/CMakeSetupDialog.cpp
+++ b/Source/MFCDialog/CMakeSetupDialog.cpp
@@ -745,19 +745,30 @@ void CMakeSetupDialog::OnChangeWhereBuild()
cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
cmCacheManager::CacheIterator it = cachem->NewIterator();
- if (cmSystemTools::FileExists(cache_file.c_str()) &&
- cachem->LoadCache(path.c_str()) &&
- it.Find("CMAKE_HOME_DIRECTORY"))
- {
- path = ConvertToWindowsPath(it.GetValue());
- this->m_WhereSource = path.c_str();
- this->m_WhereSourceControl.SetWindowText(this->m_WhereSource);
- this->OnChangeWhereSource();
- m_GeneratorPicked = true;
- }
- else
+
+ m_GeneratorPicked = false;
+
+ // make sure we have a normal cache file, specifically if one exists make
+ // sure it can be read
+ if (cmSystemTools::FileExists(cache_file.c_str()))
{
- m_GeneratorPicked = false;
+ if (cachem->LoadCache(path.c_str()))
+ {
+ if (it.Find("CMAKE_HOME_DIRECTORY"))
+ {
+ path = ConvertToWindowsPath(it.GetValue());
+ this->m_WhereSource = path.c_str();
+ this->m_WhereSourceControl.SetWindowText(this->m_WhereSource);
+ this->OnChangeWhereSource();
+ m_GeneratorPicked = true;
+ }
+ }
+ else
+ {
+ //file exists but cqnnot be read
+ cmSystemTools::Error("There is a CMakeCache.txt file for the current binary tree but cmake does not have permission to read it. Please check the permissions of the directory you are trying to run CMake on.");
+ return;
+ }
}
m_CacheEntriesList.RemoveAll();
@@ -945,7 +956,17 @@ void CMakeSetupDialog::LoadCacheFromDiskToGUI()
cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
if(m_WhereBuild != "")
{
- cachem->LoadCache(m_WhereBuild);
+ if (!cachem->LoadCache(m_WhereBuild))
+ {
+ // if it does exist, but isn;t readable then warn the user
+ std::string cacheFile = m_WhereBuild;
+ cacheFile += "/CMakeCache.txt";
+ if(cmSystemTools::FileExists(cacheFile.c_str()))
+ {
+ cmSystemTools::Error("There is a CMakeCache.txt file for the current binary tree but cmake does not have permission to read it. Please check the permissions of the directory you are trying to run CMake on.");
+ return;
+ }
+ }
cmCacheManager::CacheIterator itm = cachem->NewIterator();
if ( itm.Find("CMAKE_HOME_DIRECTORY"))
{
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index aca7ab6..9ea46c5 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -1515,7 +1515,18 @@ void cmake::AddDefaultGenerators()
int cmake::LoadCache()
{
- m_CacheManager->LoadCache(this->GetHomeOutputDirectory());
+ // could we not read the cache
+ if (!m_CacheManager->LoadCache(this->GetHomeOutputDirectory()))
+ {
+ // if it does exist, but isn;t readable then warn the user
+ std::string cacheFile = this->GetHomeOutputDirectory();
+ cacheFile += "/CMakeCache.txt";
+ if(cmSystemTools::FileExists(cacheFile.c_str()))
+ {
+ cmSystemTools::Error("There is a CMakeCache.txt file for the current binary tree but cmake does not have permission to read it. Please check the permissions of the directory you are trying to run CMake on.");
+ return -1;
+ }
+ }
if (m_CMakeCommand.size() < 2)
{