AddCacheEntry accept cmProp or std::string

This commit is contained in:
Marc Chevrier 2021-09-02 17:52:37 +02:00
parent c8991f17cf
commit 3c2e58eeb8
6 changed files with 43 additions and 7 deletions

View File

@ -521,7 +521,7 @@ void cmCacheManager::PrintCache(std::ostream& out) const
"=================================================\n";
}
void cmCacheManager::AddCacheEntry(const std::string& key, const char* value,
void cmCacheManager::AddCacheEntry(const std::string& key, cmProp value,
const char* helpString,
cmStateEnums::CacheEntryType type)
{
@ -550,10 +550,10 @@ void cmCacheManager::AddCacheEntry(const std::string& key, const char* value,
: "(This variable does not exist and should not be used)");
}
void cmCacheManager::CacheEntry::SetValue(const char* value)
void cmCacheManager::CacheEntry::SetValue(cmProp value)
{
if (value) {
this->Value = value;
this->Value = *value;
this->Initialized = true;
} else {
this->Value.clear();

View File

@ -31,7 +31,7 @@ class cmCacheManager
public:
const std::string& GetValue() const { return this->Value; }
void SetValue(const char*);
void SetValue(cmProp);
cmStateEnums::CacheEntryType GetType() const { return this->Type; }
void SetType(cmStateEnums::CacheEntryType ty) { this->Type = ty; }
@ -83,7 +83,7 @@ public:
void SetCacheEntryValue(std::string const& key, std::string const& value)
{
if (auto* entry = this->GetCacheEntry(key)) {
entry->SetValue(value.c_str());
entry->SetValue(cmProp(value));
}
}
@ -173,6 +173,18 @@ public:
//! Add an entry into the cache
void AddCacheEntry(const std::string& key, const char* value,
const char* helpString, cmStateEnums::CacheEntryType type)
{
this->AddCacheEntry(key,
value ? cmProp(std::string(value)) : cmProp(nullptr),
helpString, type);
}
void AddCacheEntry(const std::string& key, const std::string& value,
const char* helpString, cmStateEnums::CacheEntryType type)
{
this->AddCacheEntry(key, cmProp(value), helpString, type);
}
void AddCacheEntry(const std::string& key, cmProp value,
const char* helpString,
cmStateEnums::CacheEntryType type);

View File

@ -206,7 +206,7 @@ bool cmState::GetCacheEntryPropertyAsBool(std::string const& key,
return this->CacheManager->GetCacheEntryPropertyAsBool(key, propertyName);
}
void cmState::AddCacheEntry(const std::string& key, const char* value,
void cmState::AddCacheEntry(const std::string& key, cmProp value,
const char* helpString,
cmStateEnums::CacheEntryType type)
{

View File

@ -219,6 +219,18 @@ public:
private:
friend class cmake;
void AddCacheEntry(const std::string& key, const char* value,
const char* helpString, cmStateEnums::CacheEntryType type)
{
this->AddCacheEntry(key,
value ? cmProp(std::string(value)) : cmProp(nullptr),
helpString, type);
}
void AddCacheEntry(const std::string& key, const std::string& value,
const char* helpString, cmStateEnums::CacheEntryType type)
{
this->AddCacheEntry(key, cmProp(value), helpString, type);
}
void AddCacheEntry(const std::string& key, cmProp value,
const char* helpString,
cmStateEnums::CacheEntryType type);

View File

@ -2416,7 +2416,7 @@ int cmake::Generate()
return 0;
}
void cmake::AddCacheEntry(const std::string& key, const char* value,
void cmake::AddCacheEntry(const std::string& key, cmProp value,
const char* helpString, int type)
{
this->State->AddCacheEntry(key, value, helpString,

View File

@ -332,6 +332,18 @@ public:
cmProp GetCacheDefinition(const std::string&) const;
//! Add an entry into the cache
void AddCacheEntry(const std::string& key, const char* value,
const char* helpString, int type)
{
this->AddCacheEntry(key,
value ? cmProp(std::string(value)) : cmProp(nullptr),
helpString, type);
}
void AddCacheEntry(const std::string& key, const std::string& value,
const char* helpString, int type)
{
this->AddCacheEntry(key, cmProp(value), helpString, type);
}
void AddCacheEntry(const std::string& key, cmProp value,
const char* helpString, int type);
bool DoWriteGlobVerifyTarget() const;