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 == ' ' ||
|
||||||
*realbuffer == '\t' ||
|
*realbuffer == '\t' ||
|
||||||
*realbuffer == '\n'))
|
*realbuffer == '\n'))
|
||||||
{
|
{
|
||||||
realbuffer++;
|
realbuffer++;
|
||||||
}
|
}
|
||||||
// skip blank lines and comment lines
|
// skip blank lines and comment lines
|
||||||
if(realbuffer[0] == '#' || realbuffer[0] == 0)
|
if(realbuffer[0] == '#' || realbuffer[0] == 0)
|
||||||
{
|
{
|
||||||
|
@ -202,38 +202,38 @@ bool cmCacheManager::LoadCache(const char* path,
|
||||||
{
|
{
|
||||||
entryKey = reg.match(1);
|
entryKey = reg.match(1);
|
||||||
if ( excludes.find(entryKey) == excludes.end() )
|
if ( excludes.find(entryKey) == excludes.end() )
|
||||||
{
|
{
|
||||||
e.m_Type = cmCacheManager::StringToType(reg.match(2).c_str());
|
e.m_Type = cmCacheManager::StringToType(reg.match(2).c_str());
|
||||||
// only load internal values if internal is set
|
// only load internal values if internal is set
|
||||||
// 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
|
// If the entry is not internal to the cache being loaded
|
||||||
// or if it is in the list of internal entries to be
|
// or if it is in the list of internal entries to be
|
||||||
// imported, load it.
|
// imported, load it.
|
||||||
if ( internal || (e.m_Type != INTERNAL) ||
|
if ( internal || (e.m_Type != INTERNAL) ||
|
||||||
(includes.find(entryKey) != includes.end()) )
|
(includes.find(entryKey) != includes.end()) )
|
||||||
{
|
{
|
||||||
// If we are loading the cache from another project,
|
// If we are loading the cache from another project,
|
||||||
// make all loaded entries internal so that it is
|
// make all loaded entries internal so that it is
|
||||||
// not visible in the gui
|
// not visible in the gui
|
||||||
if (!internal)
|
if (!internal)
|
||||||
{
|
{
|
||||||
e.m_Type = INTERNAL;
|
e.m_Type = INTERNAL;
|
||||||
e.m_HelpString = "DO NOT EDIT, ";
|
e.m_HelpString = "DO NOT EDIT, ";
|
||||||
e.m_HelpString += entryKey;
|
e.m_HelpString += entryKey;
|
||||||
e.m_HelpString += " loaded from external file. "
|
e.m_HelpString += " loaded from external file. "
|
||||||
"To change this value edit this file: ";
|
"To change this value edit this file: ";
|
||||||
e.m_HelpString += path;
|
e.m_HelpString += path;
|
||||||
e.m_HelpString += "/CMakeCache.txt";
|
e.m_HelpString += "/CMakeCache.txt";
|
||||||
}
|
}
|
||||||
e.m_Value = reg.match(3);
|
e.m_Value = reg.match(3);
|
||||||
m_Cache[entryKey] = e;
|
m_Cache[entryKey] = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cmSystemTools::Error("Parse error in cache file ", cacheFile.c_str(),
|
cmSystemTools::Error("Parse error in cache file ", cacheFile.c_str(),
|
||||||
". Offending entry: ", realbuffer);
|
". Offending entry: ", realbuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if CMAKE version not found in the list file
|
// if CMAKE version not found in the list file
|
||||||
|
@ -248,6 +248,19 @@ bool cmCacheManager::LoadCache(const char* path,
|
||||||
"current loaded cache", cmCacheManager::INTERNAL);
|
"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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,6 +310,15 @@ bool cmCacheManager::SaveCache(const char* path)
|
||||||
this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION", temp,
|
this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION", temp,
|
||||||
"Major version of cmake used to create the "
|
"Major version of cmake used to create the "
|
||||||
"current loaded cache", cmCacheManager::INTERNAL);
|
"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"
|
fout << "# This is the CMakeCache file.\n"
|
||||||
<< "# For build in directory: " << path << "\n"
|
<< "# For build in directory: " << path << "\n"
|
||||||
<< "# You can edit this file to change values found and used by cmake.\n"
|
<< "# You can edit this file to change values found and used by cmake.\n"
|
||||||
|
|
Loading…
Reference in New Issue