Added check if the binary directory changed. If it did, it will print the warning message
This commit is contained in:
parent
959c447a6d
commit
47c7af3cc8
|
@ -151,9 +151,9 @@ bool cmCacheManager::LoadCache(const char* path,
|
|||
(*realbuffer == ' ' ||
|
||||
*realbuffer == '\t' ||
|
||||
*realbuffer == '\n'))
|
||||
{
|
||||
{
|
||||
realbuffer++;
|
||||
}
|
||||
}
|
||||
// skip blank lines and comment lines
|
||||
if(realbuffer[0] == '#' || realbuffer[0] == 0)
|
||||
{
|
||||
|
@ -202,38 +202,38 @@ bool cmCacheManager::LoadCache(const char* path,
|
|||
{
|
||||
entryKey = reg.match(1);
|
||||
if ( excludes.find(entryKey) == excludes.end() )
|
||||
{
|
||||
e.m_Type = cmCacheManager::StringToType(reg.match(2).c_str());
|
||||
// only load internal values if internal is set
|
||||
// Load internal values if internal is set.
|
||||
// If the entry is not internal to the cache being loaded
|
||||
// or if it is in the list of internal entries to be
|
||||
// imported, load it.
|
||||
if ( internal || (e.m_Type != INTERNAL) ||
|
||||
(includes.find(entryKey) != includes.end()) )
|
||||
{
|
||||
// If we are loading the cache from another project,
|
||||
// make all loaded entries internal so that it is
|
||||
// not visible in the gui
|
||||
if (!internal)
|
||||
{
|
||||
e.m_Type = INTERNAL;
|
||||
e.m_HelpString = "DO NOT EDIT, ";
|
||||
{
|
||||
e.m_Type = cmCacheManager::StringToType(reg.match(2).c_str());
|
||||
// only load internal values if internal is set
|
||||
// Load internal values if internal is set.
|
||||
// If the entry is not internal to the cache being loaded
|
||||
// or if it is in the list of internal entries to be
|
||||
// imported, load it.
|
||||
if ( internal || (e.m_Type != INTERNAL) ||
|
||||
(includes.find(entryKey) != includes.end()) )
|
||||
{
|
||||
// If we are loading the cache from another project,
|
||||
// make all loaded entries internal so that it is
|
||||
// not visible in the gui
|
||||
if (!internal)
|
||||
{
|
||||
e.m_Type = INTERNAL;
|
||||
e.m_HelpString = "DO NOT EDIT, ";
|
||||
e.m_HelpString += entryKey;
|
||||
e.m_HelpString += " loaded from external file. "
|
||||
"To change this value edit this file: ";
|
||||
e.m_HelpString += path;
|
||||
e.m_HelpString += "/CMakeCache.txt";
|
||||
}
|
||||
e.m_Value = reg.match(3);
|
||||
m_Cache[entryKey] = e;
|
||||
}
|
||||
}
|
||||
}
|
||||
e.m_Value = reg.match(3);
|
||||
m_Cache[entryKey] = e;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cmSystemTools::Error("Parse error in cache file ", cacheFile.c_str(),
|
||||
". Offending entry: ", realbuffer);
|
||||
cmSystemTools::Error("Parse error in cache file ", cacheFile.c_str(),
|
||||
". Offending entry: ", realbuffer);
|
||||
}
|
||||
}
|
||||
// if CMAKE version not found in the list file
|
||||
|
@ -248,6 +248,19 @@ bool cmCacheManager::LoadCache(const char* path,
|
|||
"current loaded cache", cmCacheManager::INTERNAL);
|
||||
|
||||
}
|
||||
std::string currentcwd = path;
|
||||
cmSystemTools::ConvertToUnixSlashes(currentcwd);
|
||||
if(internal && this->GetCacheValue("CMAKE_CACHE_CWD") &&
|
||||
std::string(this->GetCacheValue("CMAKE_CACHE_CWD")) != currentcwd)
|
||||
{
|
||||
cmSystemTools::Error("The current directory is different"
|
||||
" than the one CMake was run before."
|
||||
" The binary files will be created "
|
||||
"in the previous directory. If that "
|
||||
"is not what you want, reedit the "
|
||||
"CMakeCache.txt");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -297,6 +310,15 @@ bool cmCacheManager::SaveCache(const char* path)
|
|||
this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION", temp,
|
||||
"Major version of cmake used to create the "
|
||||
"current loaded cache", cmCacheManager::INTERNAL);
|
||||
|
||||
// Let us store the current working directory so that if somebody
|
||||
// Copies it, he will not be surprised
|
||||
std::string currentcwd = path;
|
||||
cmSystemTools::ConvertToUnixSlashes(currentcwd);
|
||||
this->AddCacheEntry("CMAKE_CACHE_CWD", currentcwd.c_str(),
|
||||
"This is the directory where cmake was running the"
|
||||
" last time", cmCacheManager::INTERNAL);
|
||||
|
||||
fout << "# This is the CMakeCache file.\n"
|
||||
<< "# For build in directory: " << path << "\n"
|
||||
<< "# You can edit this file to change values found and used by cmake.\n"
|
||||
|
|
Loading…
Reference in New Issue