Add GetSafeProperty method to cmTarget, cmGeneratorTarget and cmSourceFile
This commit is contained in:
parent
752c2721a1
commit
127094f2f0
@ -221,6 +221,15 @@ const char* cmGeneratorTarget::GetProperty(const std::string& prop) const
|
||||
return this->Target->GetProperty(prop);
|
||||
}
|
||||
|
||||
const char* cmGeneratorTarget::GetSafeProperty(const std::string& prop) const
|
||||
{
|
||||
const char* ret = this->GetProperty(prop);
|
||||
if (!ret) {
|
||||
return "";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
const char* cmGeneratorTarget::GetOutputTargetType(
|
||||
cmStateEnums::ArtifactType artifact) const
|
||||
{
|
||||
|
@ -68,7 +68,10 @@ public:
|
||||
std::string GetExportName() const;
|
||||
|
||||
std::vector<std::string> GetPropertyKeys() const;
|
||||
///! Might return a nullptr if the property is not set or invalid
|
||||
const char* GetProperty(const std::string& prop) const;
|
||||
///! Always returns a valid pointer
|
||||
const char* GetSafeProperty(const std::string& prop) const;
|
||||
bool GetPropertyAsBool(const std::string& prop) const;
|
||||
void GetSourceFiles(std::vector<cmSourceFile*>& files,
|
||||
const std::string& config) const;
|
||||
|
@ -296,6 +296,15 @@ const char* cmSourceFile::GetProperty(const std::string& prop) const
|
||||
return retVal;
|
||||
}
|
||||
|
||||
const char* cmSourceFile::GetSafeProperty(const std::string& prop) const
|
||||
{
|
||||
const char* ret = this->GetProperty(prop);
|
||||
if (!ret) {
|
||||
return "";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool cmSourceFile::GetPropertyAsBool(const std::string& prop) const
|
||||
{
|
||||
return cmSystemTools::IsOn(this->GetProperty(prop));
|
||||
|
@ -45,7 +45,10 @@ public:
|
||||
void SetProperty(const std::string& prop, const char* value);
|
||||
void AppendProperty(const std::string& prop, const char* value,
|
||||
bool asString = false);
|
||||
///! Might return a nullptr if the property is not set or invalid
|
||||
const char* GetProperty(const std::string& prop) const;
|
||||
///! Always returns a valid pointer
|
||||
const char* GetSafeProperty(const std::string& prop) const;
|
||||
bool GetPropertyAsBool(const std::string& prop) const;
|
||||
|
||||
/** Implement getting a property when called from a CMake language
|
||||
|
@ -1412,6 +1412,15 @@ const char* cmTarget::GetProperty(const std::string& prop) const
|
||||
return retVal;
|
||||
}
|
||||
|
||||
const char* cmTarget::GetSafeProperty(const std::string& prop) const
|
||||
{
|
||||
const char* ret = this->GetProperty(prop);
|
||||
if (!ret) {
|
||||
return "";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool cmTarget::GetPropertyAsBool(const std::string& prop) const
|
||||
{
|
||||
return cmSystemTools::IsOn(this->GetProperty(prop));
|
||||
|
@ -200,7 +200,10 @@ public:
|
||||
void SetProperty(const std::string& prop, const char* value);
|
||||
void AppendProperty(const std::string& prop, const char* value,
|
||||
bool asString = false);
|
||||
///! Might return a nullptr if the property is not set or invalid
|
||||
const char* GetProperty(const std::string& prop) const;
|
||||
///! Always returns a valid pointer
|
||||
const char* GetSafeProperty(const std::string& prop) const;
|
||||
bool GetPropertyAsBool(const std::string& prop) const;
|
||||
void CheckProperty(const std::string& prop, cmMakefile* context) const;
|
||||
const char* GetComputedProperty(const std::string& prop,
|
||||
|
Loading…
Reference in New Issue
Block a user