summaryrefslogtreecommitdiffstats
path: root/Source/cmCacheManager.cxx
diff options
context:
space:
mode:
authorVitaly Stakhovsky <vvs31415@gitlab.org>2018-09-06 16:49:57 (GMT)
committerVitaly Stakhovsky <vvs31415@gitlab.org>2018-09-06 16:49:57 (GMT)
commit46855d000fcd624d2e1ea3ce79d0e8c6d0ba614c (patch)
treebb3b8cb7cfd3a836db59c0edc842cb14adf8fe28 /Source/cmCacheManager.cxx
parentf782759ed0997eb3d71e1187a829da62668ed5d2 (diff)
downloadCMake-46855d000fcd624d2e1ea3ce79d0e8c6d0ba614c.zip
CMake-46855d000fcd624d2e1ea3ce79d0e8c6d0ba614c.tar.gz
CMake-46855d000fcd624d2e1ea3ce79d0e8c6d0ba614c.tar.bz2
cmCacheManager::GetInitializedCacheValue(): Return as const std::string*
Expose std::string type used internally instead of const char*
Diffstat (limited to 'Source/cmCacheManager.cxx')
-rw-r--r--Source/cmCacheManager.cxx22
1 files changed, 12 insertions, 10 deletions
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index d2d419f..b391dc4 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -127,15 +127,15 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal,
}
this->CacheMajorVersion = 0;
this->CacheMinorVersion = 0;
- if (const char* cmajor =
+ if (const std::string* cmajor =
this->GetInitializedCacheValue("CMAKE_CACHE_MAJOR_VERSION")) {
unsigned int v = 0;
- if (sscanf(cmajor, "%u", &v) == 1) {
+ if (sscanf(cmajor->c_str(), "%u", &v) == 1) {
this->CacheMajorVersion = v;
}
- if (const char* cminor =
+ if (const std::string* cminor =
this->GetInitializedCacheValue("CMAKE_CACHE_MINOR_VERSION")) {
- if (sscanf(cminor, "%u", &v) == 1) {
+ if (sscanf(cminor->c_str(), "%u", &v) == 1) {
this->CacheMinorVersion = v;
}
}
@@ -153,18 +153,20 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal,
}
// check to make sure the cache directory has not
// been moved
- const char* oldDir = this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR");
+ const std::string* oldDir =
+ this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR");
if (internal && oldDir) {
std::string currentcwd = path;
- std::string oldcwd = oldDir;
+ std::string oldcwd = *oldDir;
cmSystemTools::ConvertToUnixSlashes(currentcwd);
currentcwd += "/CMakeCache.txt";
oldcwd += "/CMakeCache.txt";
if (!cmSystemTools::SameFile(oldcwd, currentcwd)) {
+ const std::string* dir =
+ this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR");
std::ostringstream message;
message << "The current CMakeCache.txt directory " << currentcwd
- << " is different than the directory "
- << this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR")
+ << " is different than the directory " << (dir ? *dir : "")
<< " where CMakeCache.txt was created. This may result "
"in binaries being created in the wrong place. If you "
"are not sure, reedit the CMakeCache.txt";
@@ -512,12 +514,12 @@ cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator(const char* key)
return CacheIterator(*this, key);
}
-const char* cmCacheManager::GetInitializedCacheValue(
+const std::string* cmCacheManager::GetInitializedCacheValue(
const std::string& key) const
{
CacheEntryMap::const_iterator i = this->Cache.find(key);
if (i != this->Cache.end() && i->second.Initialized) {
- return i->second.Value.c_str();
+ return &i->second.Value;
}
return nullptr;
}