|
@@ -124,13 +124,13 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal,
|
|
}
|
|
}
|
|
this->CacheMajorVersion = 0;
|
|
this->CacheMajorVersion = 0;
|
|
this->CacheMinorVersion = 0;
|
|
this->CacheMinorVersion = 0;
|
|
- if (const std::string* cmajor =
|
|
|
|
|
|
+ if (cmProp cmajor =
|
|
this->GetInitializedCacheValue("CMAKE_CACHE_MAJOR_VERSION")) {
|
|
this->GetInitializedCacheValue("CMAKE_CACHE_MAJOR_VERSION")) {
|
|
unsigned int v = 0;
|
|
unsigned int v = 0;
|
|
if (sscanf(cmajor->c_str(), "%u", &v) == 1) {
|
|
if (sscanf(cmajor->c_str(), "%u", &v) == 1) {
|
|
this->CacheMajorVersion = v;
|
|
this->CacheMajorVersion = v;
|
|
}
|
|
}
|
|
- if (const std::string* cminor =
|
|
|
|
|
|
+ if (cmProp cminor =
|
|
this->GetInitializedCacheValue("CMAKE_CACHE_MINOR_VERSION")) {
|
|
this->GetInitializedCacheValue("CMAKE_CACHE_MINOR_VERSION")) {
|
|
if (sscanf(cminor->c_str(), "%u", &v) == 1) {
|
|
if (sscanf(cminor->c_str(), "%u", &v) == 1) {
|
|
this->CacheMinorVersion = v;
|
|
this->CacheMinorVersion = v;
|
|
@@ -150,8 +150,7 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal,
|
|
}
|
|
}
|
|
// check to make sure the cache directory has not
|
|
// check to make sure the cache directory has not
|
|
// been moved
|
|
// been moved
|
|
- const std::string* oldDir =
|
|
|
|
- this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR");
|
|
|
|
|
|
+ cmProp oldDir = this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR");
|
|
if (internal && oldDir) {
|
|
if (internal && oldDir) {
|
|
std::string currentcwd = path;
|
|
std::string currentcwd = path;
|
|
std::string oldcwd = *oldDir;
|
|
std::string oldcwd = *oldDir;
|
|
@@ -159,8 +158,7 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal,
|
|
currentcwd += "/CMakeCache.txt";
|
|
currentcwd += "/CMakeCache.txt";
|
|
oldcwd += "/CMakeCache.txt";
|
|
oldcwd += "/CMakeCache.txt";
|
|
if (!cmSystemTools::SameFile(oldcwd, currentcwd)) {
|
|
if (!cmSystemTools::SameFile(oldcwd, currentcwd)) {
|
|
- const std::string* dir =
|
|
|
|
- this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR");
|
|
|
|
|
|
+ cmProp dir = this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR");
|
|
std::ostringstream message;
|
|
std::ostringstream message;
|
|
message << "The current CMakeCache.txt directory " << currentcwd
|
|
message << "The current CMakeCache.txt directory " << currentcwd
|
|
<< " is different than the directory " << (dir ? *dir : "")
|
|
<< " is different than the directory " << (dir ? *dir : "")
|
|
@@ -210,7 +208,7 @@ void cmCacheManager::WritePropertyEntries(std::ostream& os, CacheIterator i,
|
|
cmMessenger* messenger)
|
|
cmMessenger* messenger)
|
|
{
|
|
{
|
|
for (const char** p = cmCacheManager::PersistentProperties; *p; ++p) {
|
|
for (const char** p = cmCacheManager::PersistentProperties; *p; ++p) {
|
|
- if (const char* value = i.GetProperty(*p)) {
|
|
|
|
|
|
+ if (cmProp value = i.GetProperty(*p)) {
|
|
std::string helpstring =
|
|
std::string helpstring =
|
|
cmStrCat(*p, " property for variable: ", i.GetName());
|
|
cmStrCat(*p, " property for variable: ", i.GetName());
|
|
cmCacheManager::OutputHelpString(os, helpstring);
|
|
cmCacheManager::OutputHelpString(os, helpstring);
|
|
@@ -218,9 +216,9 @@ void cmCacheManager::WritePropertyEntries(std::ostream& os, CacheIterator i,
|
|
std::string key = cmStrCat(i.GetName(), '-', *p);
|
|
std::string key = cmStrCat(i.GetName(), '-', *p);
|
|
cmCacheManager::OutputKey(os, key);
|
|
cmCacheManager::OutputKey(os, key);
|
|
os << ":INTERNAL=";
|
|
os << ":INTERNAL=";
|
|
- cmCacheManager::OutputValue(os, value);
|
|
|
|
|
|
+ cmCacheManager::OutputValue(os, *value);
|
|
os << "\n";
|
|
os << "\n";
|
|
- cmCacheManager::OutputNewlineTruncationWarning(os, key, value,
|
|
|
|
|
|
+ cmCacheManager::OutputNewlineTruncationWarning(os, key, *value,
|
|
messenger);
|
|
messenger);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -305,8 +303,8 @@ bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger)
|
|
*/
|
|
*/
|
|
} else if (t != cmStateEnums::INTERNAL) {
|
|
} else if (t != cmStateEnums::INTERNAL) {
|
|
// Format is key:type=value
|
|
// Format is key:type=value
|
|
- if (const char* help = ce.GetProperty("HELPSTRING")) {
|
|
|
|
- cmCacheManager::OutputHelpString(fout, help);
|
|
|
|
|
|
+ if (cmProp help = ce.GetProperty("HELPSTRING")) {
|
|
|
|
+ cmCacheManager::OutputHelpString(fout, *help);
|
|
} else {
|
|
} else {
|
|
cmCacheManager::OutputHelpString(fout, "Missing description");
|
|
cmCacheManager::OutputHelpString(fout, "Missing description");
|
|
}
|
|
}
|
|
@@ -336,8 +334,8 @@ bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger)
|
|
this->WritePropertyEntries(fout, i, messenger);
|
|
this->WritePropertyEntries(fout, i, messenger);
|
|
if (t == cmStateEnums::INTERNAL) {
|
|
if (t == cmStateEnums::INTERNAL) {
|
|
// Format is key:type=value
|
|
// Format is key:type=value
|
|
- if (const char* help = i.GetProperty("HELPSTRING")) {
|
|
|
|
- cmCacheManager::OutputHelpString(fout, help);
|
|
|
|
|
|
+ if (cmProp help = i.GetProperty("HELPSTRING")) {
|
|
|
|
+ cmCacheManager::OutputHelpString(fout, *help);
|
|
}
|
|
}
|
|
cmCacheManager::OutputKey(fout, i.GetName());
|
|
cmCacheManager::OutputKey(fout, i.GetName());
|
|
fout << ":" << cmState::CacheEntryTypeToString(t) << "=";
|
|
fout << ":" << cmState::CacheEntryTypeToString(t) << "=";
|
|
@@ -508,8 +506,7 @@ cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator()
|
|
return { *this, nullptr };
|
|
return { *this, nullptr };
|
|
}
|
|
}
|
|
|
|
|
|
-const std::string* cmCacheManager::GetInitializedCacheValue(
|
|
|
|
- const std::string& key) const
|
|
|
|
|
|
+cmProp cmCacheManager::GetInitializedCacheValue(const std::string& key) const
|
|
{
|
|
{
|
|
auto i = this->Cache.find(key);
|
|
auto i = this->Cache.find(key);
|
|
if (i != this->Cache.end() && i->second.Initialized) {
|
|
if (i != this->Cache.end() && i->second.Initialized) {
|
|
@@ -619,17 +616,15 @@ std::vector<std::string> cmCacheManager::CacheEntry::GetPropertyList() const
|
|
return this->Properties.GetKeys();
|
|
return this->Properties.GetKeys();
|
|
}
|
|
}
|
|
|
|
|
|
-const char* cmCacheManager::CacheEntry::GetProperty(
|
|
|
|
- const std::string& prop) const
|
|
|
|
|
|
+cmProp cmCacheManager::CacheEntry::GetProperty(const std::string& prop) const
|
|
{
|
|
{
|
|
if (prop == "TYPE") {
|
|
if (prop == "TYPE") {
|
|
- return cmState::CacheEntryTypeToString(this->Type).c_str();
|
|
|
|
|
|
+ return &cmState::CacheEntryTypeToString(this->Type);
|
|
}
|
|
}
|
|
if (prop == "VALUE") {
|
|
if (prop == "VALUE") {
|
|
- return this->Value.c_str();
|
|
|
|
|
|
+ return &this->Value;
|
|
}
|
|
}
|
|
- cmProp retVal = this->Properties.GetPropertyValue(prop);
|
|
|
|
- return retVal ? retVal->c_str() : nullptr;
|
|
|
|
|
|
+ return this->Properties.GetPropertyValue(prop);
|
|
}
|
|
}
|
|
|
|
|
|
void cmCacheManager::CacheEntry::SetProperty(const std::string& prop,
|
|
void cmCacheManager::CacheEntry::SetProperty(const std::string& prop,
|
|
@@ -663,7 +658,7 @@ void cmCacheManager::CacheEntry::AppendProperty(const std::string& prop,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-const char* cmCacheManager::CacheIterator::GetProperty(
|
|
|
|
|
|
+cmProp cmCacheManager::CacheIterator::GetProperty(
|
|
const std::string& prop) const
|
|
const std::string& prop) const
|
|
{
|
|
{
|
|
if (!this->IsAtEnd()) {
|
|
if (!this->IsAtEnd()) {
|
|
@@ -692,8 +687,8 @@ void cmCacheManager::CacheIterator::AppendProperty(const std::string& p,
|
|
bool cmCacheManager::CacheIterator::GetPropertyAsBool(
|
|
bool cmCacheManager::CacheIterator::GetPropertyAsBool(
|
|
const std::string& prop) const
|
|
const std::string& prop) const
|
|
{
|
|
{
|
|
- if (const char* value = this->GetProperty(prop)) {
|
|
|
|
- return cmIsOn(value);
|
|
|
|
|
|
+ if (cmProp value = this->GetProperty(prop)) {
|
|
|
|
+ return cmIsOn(*value);
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|