stringapi: Use strings for property names

Property names are always generated by CMake and should never be NULL.
This commit is contained in:
Ben Boeckel 2013-09-02 16:27:32 -04:00 committed by Brad King
parent 2977330a7b
commit ec97ed7d0c
32 changed files with 262 additions and 310 deletions

View File

@ -807,13 +807,13 @@ bool cmCacheManager::CacheIterator::GetValueAsBool() const
//----------------------------------------------------------------------------
const char*
cmCacheManager::CacheEntry::GetProperty(const char* prop) const
cmCacheManager::CacheEntry::GetProperty(const std::string& prop) const
{
if(strcmp(prop, "TYPE") == 0)
if(prop == "TYPE")
{
return cmCacheManagerTypes[this->Type];
}
else if(strcmp(prop, "VALUE") == 0)
else if(prop == "VALUE")
{
return this->Value.c_str();
}
@ -823,14 +823,14 @@ cmCacheManager::CacheEntry::GetProperty(const char* prop) const
}
//----------------------------------------------------------------------------
void cmCacheManager::CacheEntry::SetProperty(const char* prop,
void cmCacheManager::CacheEntry::SetProperty(const std::string& prop,
const char* value)
{
if(strcmp(prop, "TYPE") == 0)
if(prop == "TYPE")
{
this->Type = cmCacheManager::StringToType(value? value : "STRING");
}
else if(strcmp(prop, "VALUE") == 0)
else if(prop == "VALUE")
{
this->Value = value? value : "";
}
@ -841,15 +841,15 @@ void cmCacheManager::CacheEntry::SetProperty(const char* prop,
}
//----------------------------------------------------------------------------
void cmCacheManager::CacheEntry::AppendProperty(const char* prop,
void cmCacheManager::CacheEntry::AppendProperty(const std::string& prop,
const char* value,
bool asString)
{
if(strcmp(prop, "TYPE") == 0)
if(prop == "TYPE")
{
this->Type = cmCacheManager::StringToType(value? value : "STRING");
}
else if(strcmp(prop, "VALUE") == 0)
else if(prop == "VALUE")
{
if(value)
{
@ -867,7 +867,8 @@ void cmCacheManager::CacheEntry::AppendProperty(const char* prop,
}
//----------------------------------------------------------------------------
const char* cmCacheManager::CacheIterator::GetProperty(const char* prop) const
const char* cmCacheManager::CacheIterator::GetProperty(
const std::string& prop) const
{
if(!this->IsAtEnd())
{
@ -877,7 +878,8 @@ const char* cmCacheManager::CacheIterator::GetProperty(const char* prop) const
}
//----------------------------------------------------------------------------
void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v)
void cmCacheManager::CacheIterator::SetProperty(const std::string& p,
const char* v)
{
if(!this->IsAtEnd())
{
@ -886,7 +888,7 @@ void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v)
}
//----------------------------------------------------------------------------
void cmCacheManager::CacheIterator::AppendProperty(const char* p,
void cmCacheManager::CacheIterator::AppendProperty(const std::string& p,
const char* v,
bool asString)
{
@ -897,7 +899,8 @@ void cmCacheManager::CacheIterator::AppendProperty(const char* p,
}
//----------------------------------------------------------------------------
bool cmCacheManager::CacheIterator::GetPropertyAsBool(const char* prop) const
bool cmCacheManager::CacheIterator::GetPropertyAsBool(
const std::string& prop) const
{
if(const char* value = this->GetProperty(prop))
{
@ -907,13 +910,14 @@ bool cmCacheManager::CacheIterator::GetPropertyAsBool(const char* prop) const
}
//----------------------------------------------------------------------------
void cmCacheManager::CacheIterator::SetProperty(const char* p, bool v)
void cmCacheManager::CacheIterator::SetProperty(const std::string& p, bool v)
{
this->SetProperty(p, v ? "ON" : "OFF");
}
//----------------------------------------------------------------------------
bool cmCacheManager::CacheIterator::PropertyExists(const char* prop) const
bool cmCacheManager::CacheIterator::PropertyExists(
const std::string& prop) const
{
return this->GetProperty(prop)? true:false;
}

View File

@ -39,9 +39,9 @@ private:
std::string Value;
CacheEntryType Type;
cmPropertyMap Properties;
const char* GetProperty(const char*) const;
void SetProperty(const char* property, const char* value);
void AppendProperty(const char* property, const char* value,
const char* GetProperty(const std::string&) const;
void SetProperty(const std::string& property, const char* value);
void AppendProperty(const std::string& property, const char* value,
bool asString=false);
bool Initialized;
CacheEntry() : Value(""), Type(UNINITIALIZED), Initialized(false)
@ -58,13 +58,13 @@ public:
void Next();
const char *GetName() const {
return this->Position->first.c_str(); }
const char* GetProperty(const char*) const ;
bool GetPropertyAsBool(const char*) const ;
bool PropertyExists(const char*) const;
void SetProperty(const char* property, const char* value);
void AppendProperty(const char* property, const char* value,
const char* GetProperty(const std::string&) const ;
bool GetPropertyAsBool(const std::string&) const ;
bool PropertyExists(const std::string&) const;
void SetProperty(const std::string& property, const char* value);
void AppendProperty(const std::string& property, const char* value,
bool asString=false);
void SetProperty(const char* property, bool value);
void SetProperty(const std::string& property, bool value);
const char* GetValue() const { return this->GetEntry().Value.c_str(); }
bool GetValueAsBool() const;
void SetValue(const char*);

View File

@ -136,7 +136,8 @@ void cmExportFileGenerator::GenerateImportConfig(std::ostream& os,
}
//----------------------------------------------------------------------------
void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName,
void cmExportFileGenerator::PopulateInterfaceProperty(
const std::string& propName,
cmTarget *target,
ImportPropertyMap &properties)
{
@ -148,8 +149,9 @@ void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName,
}
//----------------------------------------------------------------------------
void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName,
const char *outputName,
void cmExportFileGenerator::PopulateInterfaceProperty(
const std::string& propName,
const cmStdString& outputName,
cmTarget *target,
cmGeneratorExpression::PreprocessContext preprocessRule,
ImportPropertyMap &properties,
@ -391,7 +393,8 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
}
//----------------------------------------------------------------------------
void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName,
void cmExportFileGenerator::PopulateInterfaceProperty(
const std::string& propName,
cmTarget *target,
cmGeneratorExpression::PreprocessContext preprocessRule,
ImportPropertyMap &properties,
@ -403,7 +406,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName,
//----------------------------------------------------------------------------
void getPropertyContents(cmTarget const* tgt, const char *prop,
void getPropertyContents(cmTarget const* tgt, const std::string& prop,
std::set<std::string> &ifaceProperties)
{
const char *p = tgt->GetProperty(prop);
@ -825,7 +828,7 @@ void
cmExportFileGenerator
::SetImportLinkProperty(std::string const& suffix,
cmTarget* target,
const char* propName,
const std::string& propName,
std::vector<std::string> const& entries,
ImportPropertyMap& properties,
std::vector<std::string>& missingTargets

View File

@ -95,7 +95,7 @@ protected:
ImportPropertyMap& properties,
std::vector<std::string>& missingTargets);
void SetImportLinkProperty(std::string const& suffix,
cmTarget* target, const char* propName,
cmTarget* target, const std::string& propName,
std::vector<std::string> const& entries,
ImportPropertyMap& properties,
std::vector<std::string>& missingTargets);
@ -116,7 +116,7 @@ protected:
cmMakefile* mf,
cmTarget* depender,
cmTarget* dependee) = 0;
void PopulateInterfaceProperty(const char *,
void PopulateInterfaceProperty(const std::string&,
cmTarget *target,
cmGeneratorExpression::PreprocessContext,
ImportPropertyMap &properties,
@ -125,7 +125,7 @@ protected:
cmGeneratorExpression::PreprocessContext,
ImportPropertyMap &properties,
std::vector<std::string> &missingTargets);
void PopulateInterfaceProperty(const char *propName, cmTarget *target,
void PopulateInterfaceProperty(const std::string& propName, cmTarget *target,
ImportPropertyMap &properties);
void PopulateCompatibleInterfaceProperties(cmTarget *target,
ImportPropertyMap &properties);
@ -174,7 +174,7 @@ protected:
std::set<cmTarget*> ExportedTargets;
private:
void PopulateInterfaceProperty(const char *, const char *,
void PopulateInterfaceProperty(const std::string&, const cmStdString&,
cmTarget *target,
cmGeneratorExpression::PreprocessContext,
ImportPropertyMap &properties,

View File

@ -46,8 +46,9 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os)
return true;
}
std::string cmExportTryCompileFileGenerator::FindTargets(const char *propName,
cmTarget const* tgt,
std::string cmExportTryCompileFileGenerator::FindTargets(
const std::string& propName,
cmTarget const* tgt,
std::set<cmTarget const*> &emitted)
{
const char *prop = tgt->GetProperty(propName);

View File

@ -46,7 +46,7 @@ protected:
std::string InstallNameDir(cmTarget* target,
const std::string& config);
private:
std::string FindTargets(const char *prop, cmTarget const* tgt,
std::string FindTargets(const std::string& prop, cmTarget const* tgt,
std::set<cmTarget const*> &emitted);

View File

@ -234,7 +234,7 @@ const char *cmGeneratorTarget::GetName() const
}
//----------------------------------------------------------------------------
const char *cmGeneratorTarget::GetProperty(const char *prop) const
const char *cmGeneratorTarget::GetProperty(const std::string& prop) const
{
return this->Target->GetProperty(prop);
}
@ -486,7 +486,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir,
}
//----------------------------------------------------------------------------
bool cmGeneratorTarget::GetPropertyAsBool(const char *prop) const
bool cmGeneratorTarget::GetPropertyAsBool(const std::string& prop) const
{
return this->Target->GetPropertyAsBool(prop);
}

View File

@ -28,8 +28,8 @@ public:
int GetType() const;
const char *GetName() const;
const char *GetProperty(const char *prop) const;
bool GetPropertyAsBool(const char *prop) const;
const char *GetProperty(const std::string& prop) const;
bool GetPropertyAsBool(const std::string& prop) const;
void GetSourceFiles(std::vector<cmSourceFile*>& files) const;
void GetObjectSources(std::vector<cmSourceFile*> &) const;

View File

@ -22,7 +22,7 @@ bool cmGetTargetPropertyCommand
}
std::string var = args[0].c_str();
const std::string& targetName = args[1];
const char *prop = 0;
std::string prop;
if(args[2] == "ALIASED_TARGET")
{
@ -38,7 +38,11 @@ bool cmGetTargetPropertyCommand
else if(cmTarget* tgt = this->Makefile->FindTargetToUse(targetName))
{
cmTarget& target = *tgt;
prop = target.GetProperty(args[2].c_str());
const char* prop_cstr = target.GetProperty(args[2].c_str());
if(prop_cstr)
{
prop = prop_cstr;
}
}
else
{
@ -70,9 +74,9 @@ bool cmGetTargetPropertyCommand
}
}
}
if (prop)
if (!prop.empty())
{
this->Makefile->AddDefinition(var.c_str(), prop);
this->Makefile->AddDefinition(var.c_str(), prop.c_str());
return true;
}
this->Makefile->AddDefinition(var.c_str(), (var+"-NOTFOUND").c_str());

View File

@ -1156,8 +1156,11 @@ void
cmLocalGenerator::ExpandRuleVariables(std::string& s,
const RuleVariables& replaceValues)
{
this->InsertRuleLauncher(s, replaceValues.CMTarget,
replaceValues.RuleLauncher);
if(replaceValues.RuleLauncher)
{
this->InsertRuleLauncher(s, replaceValues.CMTarget,
replaceValues.RuleLauncher);
}
std::string::size_type start = s.find('<');
// no variables to expand
if(start == s.npos)
@ -1201,7 +1204,7 @@ cmLocalGenerator::ExpandRuleVariables(std::string& s,
//----------------------------------------------------------------------------
const char* cmLocalGenerator::GetRuleLauncher(cmTarget* target,
const char* prop)
const std::string& prop)
{
if(target)
{
@ -1215,7 +1218,7 @@ const char* cmLocalGenerator::GetRuleLauncher(cmTarget* target,
//----------------------------------------------------------------------------
void cmLocalGenerator::InsertRuleLauncher(std::string& s, cmTarget* target,
const char* prop)
const std::string& prop)
{
if(const char* val = this->GetRuleLauncher(target, prop))
{
@ -3455,11 +3458,12 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const
}
//----------------------------------------------------------------------------
static void cmLGInfoProp(cmMakefile* mf, cmTarget* target, const char* prop)
static void cmLGInfoProp(cmMakefile* mf, cmTarget* target,
const std::string& prop)
{
if(const char* val = target->GetProperty(prop))
{
mf->AddDefinition(prop, val);
mf->AddDefinition(prop.c_str(), val);
}
}

View File

@ -382,9 +382,9 @@ protected:
std::string ExpandRuleVariable(std::string const& variable,
const RuleVariables& replaceValues);
const char* GetRuleLauncher(cmTarget* target, const char* prop);
const char* GetRuleLauncher(cmTarget* target, const std::string& prop);
void InsertRuleLauncher(std::string& s, cmTarget* target,
const char* prop);
const std::string& prop);
/** Convert a target to a utility target for unsupported

View File

@ -3548,17 +3548,9 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
return res;
}
void cmMakefile::SetProperty(const char* prop, const char* value)
void cmMakefile::SetProperty(const std::string& prop, const char* value)
{
if (!prop)
{
return;
}
// handle special props
std::string propname = prop;
if ( propname == "LINK_DIRECTORIES" )
if ( prop == "LINK_DIRECTORIES" )
{
std::vector<std::string> varArgsExpanded;
if(value)
@ -3568,7 +3560,7 @@ void cmMakefile::SetProperty(const char* prop, const char* value)
this->SetLinkDirectories(varArgsExpanded);
return;
}
if (propname == "INCLUDE_DIRECTORIES")
if (prop == "INCLUDE_DIRECTORIES")
{
this->IncludeDirectoriesEntries.clear();
if (!value)
@ -3581,7 +3573,7 @@ void cmMakefile::SetProperty(const char* prop, const char* value)
cmValueWithOrigin(value, lfbt));
return;
}
if (propname == "COMPILE_OPTIONS")
if (prop == "COMPILE_OPTIONS")
{
this->CompileOptionsEntries.clear();
if (!value)
@ -3593,7 +3585,7 @@ void cmMakefile::SetProperty(const char* prop, const char* value)
this->CompileOptionsEntries.push_back(cmValueWithOrigin(value, lfbt));
return;
}
if (propname == "COMPILE_DEFINITIONS")
if (prop == "COMPILE_DEFINITIONS")
{
this->CompileDefinitionsEntries.clear();
if (!value)
@ -3607,13 +3599,13 @@ void cmMakefile::SetProperty(const char* prop, const char* value)
return;
}
if ( propname == "INCLUDE_REGULAR_EXPRESSION" )
if ( prop == "INCLUDE_REGULAR_EXPRESSION" )
{
this->SetIncludeRegularExpression(value);
return;
}
if ( propname == "ADDITIONAL_MAKE_CLEAN_FILES" )
if ( prop == "ADDITIONAL_MAKE_CLEAN_FILES" )
{
// This property is not inherrited
if ( strcmp(this->GetCurrentDirectory(),
@ -3626,18 +3618,11 @@ void cmMakefile::SetProperty(const char* prop, const char* value)
this->Properties.SetProperty(prop,value,cmProperty::DIRECTORY);
}
void cmMakefile::AppendProperty(const char* prop, const char* value,
void cmMakefile::AppendProperty(const std::string& prop,
const char* value,
bool asString)
{
if (!prop)
{
return;
}
// handle special props
std::string propname = prop;
if (propname == "INCLUDE_DIRECTORIES")
if (prop == "INCLUDE_DIRECTORIES")
{
cmListFileBacktrace lfbt;
this->GetBacktrace(lfbt);
@ -3645,7 +3630,7 @@ void cmMakefile::AppendProperty(const char* prop, const char* value,
cmValueWithOrigin(value, lfbt));
return;
}
if (propname == "COMPILE_OPTIONS")
if (prop == "COMPILE_OPTIONS")
{
cmListFileBacktrace lfbt;
this->GetBacktrace(lfbt);
@ -3653,7 +3638,7 @@ void cmMakefile::AppendProperty(const char* prop, const char* value,
cmValueWithOrigin(value, lfbt));
return;
}
if (propname == "COMPILE_DEFINITIONS")
if (prop == "COMPILE_DEFINITIONS")
{
cmListFileBacktrace lfbt;
this->GetBacktrace(lfbt);
@ -3661,7 +3646,7 @@ void cmMakefile::AppendProperty(const char* prop, const char* value,
cmValueWithOrigin(value, lfbt));
return;
}
if ( propname == "LINK_DIRECTORIES" )
if ( prop == "LINK_DIRECTORIES" )
{
std::vector<std::string> varArgsExpanded;
cmSystemTools::ExpandListArgument(value, varArgsExpanded);
@ -3676,32 +3661,28 @@ void cmMakefile::AppendProperty(const char* prop, const char* value,
this->Properties.AppendProperty(prop,value,cmProperty::DIRECTORY,asString);
}
const char *cmMakefile::GetPropertyOrDefinition(const char* prop) const
const char *cmMakefile::GetPropertyOrDefinition(const std::string& prop) const
{
const char *ret = this->GetProperty(prop, cmProperty::DIRECTORY);
if (!ret)
{
ret = this->GetDefinition(prop);
ret = this->GetDefinition(prop.c_str());
}
return ret;
}
const char *cmMakefile::GetProperty(const char* prop) const
const char *cmMakefile::GetProperty(const std::string& prop) const
{
return this->GetProperty(prop, cmProperty::DIRECTORY);
}
const char *cmMakefile::GetProperty(const char* prop,
const char *cmMakefile::GetProperty(const std::string& prop,
cmProperty::ScopeType scope) const
{
if(!prop)
{
return 0;
}
// watch for specific properties
static std::string output;
output = "";
if (!strcmp("PARENT_DIRECTORY",prop))
if (prop == "PARENT_DIRECTORY")
{
if(cmLocalGenerator* plg = this->LocalGenerator->GetParent())
{
@ -3709,12 +3690,12 @@ const char *cmMakefile::GetProperty(const char* prop,
}
return output.c_str();
}
else if (!strcmp("INCLUDE_REGULAR_EXPRESSION",prop) )
else if (prop == "INCLUDE_REGULAR_EXPRESSION" )
{
output = this->GetIncludeRegularExpression();
return output.c_str();
}
else if (!strcmp("LISTFILE_STACK",prop))
else if (prop == "LISTFILE_STACK")
{
for (std::deque<cmStdString>::const_iterator
i = this->ListFileStack.begin();
@ -3728,10 +3709,10 @@ const char *cmMakefile::GetProperty(const char* prop,
}
return output.c_str();
}
else if (!strcmp("VARIABLES",prop) || !strcmp("CACHE_VARIABLES",prop))
else if (prop == "VARIABLES" || prop == "CACHE_VARIABLES")
{
int cacheonly = 0;
if ( !strcmp("CACHE_VARIABLES",prop) )
if ( prop == "CACHE_VARIABLES" )
{
cacheonly = 1;
}
@ -3746,17 +3727,17 @@ const char *cmMakefile::GetProperty(const char* prop,
}
return output.c_str();
}
else if (!strcmp("MACROS",prop))
else if (prop == "MACROS")
{
this->GetListOfMacros(output);
return output.c_str();
}
else if (!strcmp("DEFINITIONS",prop))
else if (prop == "DEFINITIONS")
{
output += this->DefineFlagsOrig;
return output.c_str();
}
else if (!strcmp("LINK_DIRECTORIES",prop))
else if (prop == "LINK_DIRECTORIES")
{
cmOStringStream str;
for (std::vector<std::string>::const_iterator
@ -3773,7 +3754,7 @@ const char *cmMakefile::GetProperty(const char* prop,
output = str.str();
return output.c_str();
}
else if (!strcmp("INCLUDE_DIRECTORIES",prop))
else if (prop == "INCLUDE_DIRECTORIES")
{
std::string sep;
for (std::vector<cmValueWithOrigin>::const_iterator
@ -3787,7 +3768,7 @@ const char *cmMakefile::GetProperty(const char* prop,
}
return output.c_str();
}
else if (!strcmp("COMPILE_OPTIONS",prop))
else if (prop == "COMPILE_OPTIONS")
{
std::string sep;
for (std::vector<cmValueWithOrigin>::const_iterator
@ -3801,7 +3782,7 @@ const char *cmMakefile::GetProperty(const char* prop,
}
return output.c_str();
}
else if (!strcmp("COMPILE_DEFINITIONS",prop))
else if (prop == "COMPILE_DEFINITIONS")
{
std::string sep;
for (std::vector<cmValueWithOrigin>::const_iterator
@ -3832,7 +3813,7 @@ const char *cmMakefile::GetProperty(const char* prop,
return retVal;
}
bool cmMakefile::GetPropertyAsBool(const char* prop) const
bool cmMakefile::GetPropertyAsBool(const std::string& prop) const
{
return cmSystemTools::IsOn(this->GetProperty(prop));
}
@ -4014,9 +3995,9 @@ void cmMakefile::PopScope()
}
}
void cmMakefile::RaiseScope(const char *var, const char *varDef)
void cmMakefile::RaiseScope(const cmStdString& var, const char *varDef)
{
if (!var || !strlen(var))
if (var.empty())
{
return;
}
@ -4025,10 +4006,10 @@ void cmMakefile::RaiseScope(const char *var, const char *varDef)
if(cmDefinitions* up = cur.GetParent())
{
// First localize the definition in the current scope.
cur.Get(var);
cur.Get(var.c_str());
// Now update the definition in the parent scope.
up->Set(var, varDef);
up->Set(var.c_str(), varDef);
}
else if(cmLocalGenerator* plg = this->LocalGenerator->GetParent())
{
@ -4038,11 +4019,11 @@ void cmMakefile::RaiseScope(const char *var, const char *varDef)
cmMakefile* parent = plg->GetMakefile();
if (varDef)
{
parent->AddDefinition(var, varDef);
parent->AddDefinition(var.c_str(), varDef);
}
else
{
parent->RemoveDefinition(var);
parent->RemoveDefinition(var.c_str());
}
}
else

View File

@ -800,12 +800,14 @@ public:
std::string GetModulesFile(const char* name) const;
///! Set/Get a property of this directory
void SetProperty(const char *prop, const char *value);
void AppendProperty(const char *prop, const char *value,bool asString=false);
const char *GetProperty(const char *prop) const;
const char *GetPropertyOrDefinition(const char *prop) const;
const char *GetProperty(const char *prop, cmProperty::ScopeType scope) const;
bool GetPropertyAsBool(const char *prop) const;
void SetProperty(const std::string& prop, const char *value);
void AppendProperty(const std::string& prop, const char *value,
bool asString=false);
const char *GetProperty(const std::string& prop) const;
const char *GetPropertyOrDefinition(const std::string& prop) const;
const char *GetProperty(const std::string& prop,
cmProperty::ScopeType scope) const;
bool GetPropertyAsBool(const std::string& prop) const;
const char* GetFeature(const char* feature, const char* config);
@ -835,7 +837,7 @@ public:
// push and pop variable scopes
void PushScope();
void PopScope();
void RaiseScope(const char *var, const char *value);
void RaiseScope(const cmStdString& var, const char *value);
/** Helper class to push and pop scopes automatically. */
class ScopePushPop

View File

@ -12,14 +12,15 @@
#include "cmProperty.h"
#include "cmSystemTools.h"
void cmProperty::Set(const char *name, const char *value)
void cmProperty::Set(const std::string& name, const char *value)
{
this->Name = name;
this->Value = value;
this->ValueHasBeenSet = true;
}
void cmProperty::Append(const char *name, const char *value, bool asString)
void cmProperty::Append(const std::string& name, const char *value,
bool asString)
{
this->Name = name;
if(!this->Value.empty() && *value && !asString)

View File

@ -21,10 +21,11 @@ public:
TEST, VARIABLE, CACHED_VARIABLE };
// set this property
void Set(const char *name, const char *value);
void Set(const std::string& name, const char *value);
// append to this property
void Append(const char *name, const char *value, bool asString = false);
void Append(const std::string& name, const char *value,
bool asString = false);
// get the value
const char *GetValue() const;

View File

@ -13,7 +13,7 @@
#include "cmSystemTools.h"
void cmPropertyDefinition
::DefineProperty(const char *name, cmProperty::ScopeType scope,
::DefineProperty(const std::string& name, cmProperty::ScopeType scope,
const char *shortDescription,
const char *fullDescription,
bool chain)

View File

@ -27,7 +27,7 @@ class cmPropertyDefinition
{
public:
/// Define this property
void DefineProperty(const char *name, cmProperty::ScopeType scope,
void DefineProperty(const std::string& name, cmProperty::ScopeType scope,
const char *ShortDescription,
const char *FullDescription,
bool chained);

View File

@ -14,16 +14,11 @@
#include "cmDocumentationSection.h"
void cmPropertyDefinitionMap
::DefineProperty(const char *name, cmProperty::ScopeType scope,
::DefineProperty(const cmStdString& name, cmProperty::ScopeType scope,
const char *ShortDescription,
const char *FullDescription,
bool chain)
{
if (!name)
{
return;
}
cmPropertyDefinitionMap::iterator it = this->find(name);
cmPropertyDefinition *prop;
if (it == this->end())
@ -34,13 +29,8 @@ void cmPropertyDefinitionMap
}
}
bool cmPropertyDefinitionMap::IsPropertyDefined(const char *name)
bool cmPropertyDefinitionMap::IsPropertyDefined(const cmStdString& name)
{
if (!name)
{
return false;
}
cmPropertyDefinitionMap::iterator it = this->find(name);
if (it == this->end())
{
@ -50,13 +40,8 @@ bool cmPropertyDefinitionMap::IsPropertyDefined(const char *name)
return true;
}
bool cmPropertyDefinitionMap::IsPropertyChained(const char *name)
bool cmPropertyDefinitionMap::IsPropertyChained(const cmStdString& name)
{
if (!name)
{
return false;
}
cmPropertyDefinitionMap::iterator it = this->find(name);
if (it == this->end())
{

View File

@ -21,16 +21,16 @@ public std::map<cmStdString,cmPropertyDefinition>
{
public:
// define the property
void DefineProperty(const char *name, cmProperty::ScopeType scope,
void DefineProperty(const cmStdString& name, cmProperty::ScopeType scope,
const char *ShortDescription,
const char *FullDescription,
bool chain);
// has a named property been defined
bool IsPropertyDefined(const char *name);
bool IsPropertyDefined(const cmStdString& name);
// is a named property set to chain
bool IsPropertyChained(const char *name);
bool IsPropertyChained(const cmStdString& name);
};
#endif

View File

@ -13,7 +13,7 @@
#include "cmSystemTools.h"
#include "cmake.h"
cmProperty *cmPropertyMap::GetOrCreateProperty(const char *name)
cmProperty *cmPropertyMap::GetOrCreateProperty(const std::string& name)
{
cmPropertyMap::iterator it = this->find(name);
cmProperty *prop;
@ -28,13 +28,9 @@ cmProperty *cmPropertyMap::GetOrCreateProperty(const char *name)
return prop;
}
void cmPropertyMap::SetProperty(const char *name, const char *value,
void cmPropertyMap::SetProperty(const std::string& name, const char *value,
cmProperty::ScopeType scope)
{
if (!name)
{
return;
}
if(!value)
{
this->erase(name);
@ -46,11 +42,11 @@ void cmPropertyMap::SetProperty(const char *name, const char *value,
prop->Set(name,value);
}
void cmPropertyMap::AppendProperty(const char* name, const char* value,
void cmPropertyMap::AppendProperty(const std::string& name, const char* value,
cmProperty::ScopeType scope, bool asString)
{
// Skip if nothing to append.
if(!name || !value || !*value)
if(!value || !*value)
{
return;
}
@ -61,12 +57,12 @@ void cmPropertyMap::AppendProperty(const char* name, const char* value,
}
const char *cmPropertyMap
::GetPropertyValue(const char *name,
::GetPropertyValue(const std::string& name,
cmProperty::ScopeType scope,
bool &chain) const
{
chain = false;
if (!name)
if (name.empty())
{
return 0;
}

View File

@ -19,15 +19,15 @@ class cmake;
class cmPropertyMap : public std::map<cmStdString,cmProperty>
{
public:
cmProperty *GetOrCreateProperty(const char *name);
cmProperty *GetOrCreateProperty(const std::string& name);
void SetProperty(const char *name, const char *value,
void SetProperty(const std::string& name, const char *value,
cmProperty::ScopeType scope);
void AppendProperty(const char* name, const char* value,
void AppendProperty(const std::string& name, const char* value,
cmProperty::ScopeType scope, bool asString=false);
const char *GetPropertyValue(const char *name,
const char *GetPropertyValue(const std::string& name,
cmProperty::ScopeType scope,
bool &chain) const;

View File

@ -105,7 +105,7 @@ static std::string extractSubDir(const std::string& absPath,
static void copyTargetProperty(cmTarget* destinationTarget,
cmTarget* sourceTarget,
const char* propertyName)
const std::string& propertyName)
{
const char* propertyValue = sourceTarget->GetProperty(propertyName);
if (propertyValue)

View File

@ -279,13 +279,8 @@ bool cmSourceFile::Matches(cmSourceFileLocation const& loc)
}
//----------------------------------------------------------------------------
void cmSourceFile::SetProperty(const char* prop, const char* value)
void cmSourceFile::SetProperty(const std::string& prop, const char* value)
{
if (!prop)
{
return;
}
this->Properties.SetProperty(prop, value, cmProperty::SOURCE_FILE);
std::string ext =
@ -293,7 +288,7 @@ void cmSourceFile::SetProperty(const char* prop, const char* value)
if (ext == ".ui")
{
cmMakefile const* mf = this->Location.GetMakefile();
if (strcmp(prop, "AUTOUIC_OPTIONS") == 0)
if (prop == "AUTOUIC_OPTIONS")
{
const_cast<cmMakefile*>(mf)->AddQtUiFileWithOptions(this);
}
@ -301,19 +296,15 @@ void cmSourceFile::SetProperty(const char* prop, const char* value)
}
//----------------------------------------------------------------------------
void cmSourceFile::AppendProperty(const char* prop, const char* value,
void cmSourceFile::AppendProperty(const std::string& prop, const char* value,
bool asString)
{
if (!prop)
{
return;
}
this->Properties.AppendProperty(prop, value, cmProperty::SOURCE_FILE,
asString);
}
//----------------------------------------------------------------------------
const char* cmSourceFile::GetPropertyForUser(const char *prop)
const char* cmSourceFile::GetPropertyForUser(const std::string& prop)
{
// This method is a consequence of design history and backwards
// compatibility. GetProperty is (and should be) a const method.
@ -329,7 +320,7 @@ const char* cmSourceFile::GetPropertyForUser(const char *prop)
// cmSourceFileLocation class to commit to a particular full path to
// the source file as late as possible. If the users requests the
// LOCATION property we must commit now.
if(strcmp(prop, "LOCATION") == 0)
if(prop == "LOCATION")
{
// Commit to a location.
this->GetFullPath();
@ -340,10 +331,10 @@ const char* cmSourceFile::GetPropertyForUser(const char *prop)
}
//----------------------------------------------------------------------------
const char* cmSourceFile::GetProperty(const char* prop) const
const char* cmSourceFile::GetProperty(const std::string& prop) const
{
// Check for computed properties.
if(strcmp(prop, "LOCATION") == 0)
if(prop == "LOCATION")
{
if(this->FullPath.empty())
{
@ -368,7 +359,7 @@ const char* cmSourceFile::GetProperty(const char* prop) const
}
//----------------------------------------------------------------------------
bool cmSourceFile::GetPropertyAsBool(const char* prop) const
bool cmSourceFile::GetPropertyAsBool(const std::string& prop) const
{
return cmSystemTools::IsOn(this->GetProperty(prop));
}

View File

@ -43,14 +43,15 @@ public:
void SetCustomCommand(cmCustomCommand *cc);
///! Set/Get a property of this source file
void SetProperty(const char *prop, const char *value);
void AppendProperty(const char* prop, const char* value,bool asString=false);
const char *GetProperty(const char *prop) const;
bool GetPropertyAsBool(const char *prop) const;
void SetProperty(const std::string& prop, const char *value);
void AppendProperty(const std::string& prop,
const char* value,bool asString=false);
const char *GetProperty(const std::string& prop) const;
bool GetPropertyAsBool(const std::string& prop) const;
/** Implement getting a property when called from a CMake language
command like get_property or get_source_file_property. */
const char* GetPropertyForUser(const char *prop);
const char* GetPropertyForUser(const std::string& prop);
/**
* The full path to the file. The non-const version of this method

View File

@ -1293,7 +1293,7 @@ void cmTarget::GatherDependencies( const cmMakefile& mf,
}
//----------------------------------------------------------------------------
static bool whiteListedInterfaceProperty(const char *prop)
static bool whiteListedInterfaceProperty(const std::string& prop)
{
if(cmHasLiteralPrefix(prop, "INTERFACE_"))
{
@ -1313,8 +1313,8 @@ static bool whiteListedInterfaceProperty(const char *prop)
if (std::binary_search(cmArrayBegin(builtIns),
cmArrayEnd(builtIns),
prop,
cmStrCmp(prop)))
prop.c_str(),
cmStrCmp(prop.c_str())))
{
return true;
}
@ -1328,12 +1328,8 @@ static bool whiteListedInterfaceProperty(const char *prop)
}
//----------------------------------------------------------------------------
void cmTarget::SetProperty(const char* prop, const char* value)
void cmTarget::SetProperty(const std::string& prop, const char* value)
{
if (!prop)
{
return;
}
if (this->GetType() == INTERFACE_LIBRARY
&& !whiteListedInterfaceProperty(prop))
{
@ -1344,14 +1340,14 @@ void cmTarget::SetProperty(const char* prop, const char* value)
return;
}
if (strcmp(prop, "NAME") == 0)
if (prop == "NAME")
{
cmOStringStream e;
e << "NAME property is read-only\n";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
return;
}
if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0)
if(prop == "INCLUDE_DIRECTORIES")
{
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
@ -1362,7 +1358,7 @@ void cmTarget::SetProperty(const char* prop, const char* value)
new cmTargetInternals::TargetPropertyEntry(cge));
return;
}
if(strcmp(prop,"COMPILE_OPTIONS") == 0)
if(prop == "COMPILE_OPTIONS")
{
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
@ -1373,7 +1369,7 @@ void cmTarget::SetProperty(const char* prop, const char* value)
new cmTargetInternals::TargetPropertyEntry(cge));
return;
}
if(strcmp(prop,"COMPILE_DEFINITIONS") == 0)
if(prop == "COMPILE_DEFINITIONS")
{
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
@ -1384,7 +1380,7 @@ void cmTarget::SetProperty(const char* prop, const char* value)
new cmTargetInternals::TargetPropertyEntry(cge));
return;
}
if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported())
if(prop == "EXPORT_NAME" && this->IsImported())
{
cmOStringStream e;
e << "EXPORT_NAME property can't be set on imported targets (\""
@ -1392,7 +1388,7 @@ void cmTarget::SetProperty(const char* prop, const char* value)
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
return;
}
if (strcmp(prop, "LINK_LIBRARIES") == 0)
if (prop == "LINK_LIBRARIES")
{
this->Internal->LinkImplementationPropertyEntries.clear();
cmListFileBacktrace lfbt;
@ -1406,13 +1402,9 @@ void cmTarget::SetProperty(const char* prop, const char* value)
}
//----------------------------------------------------------------------------
void cmTarget::AppendProperty(const char* prop, const char* value,
void cmTarget::AppendProperty(const std::string& prop, const char* value,
bool asString)
{
if (!prop)
{
return;
}
if (this->GetType() == INTERFACE_LIBRARY
&& !whiteListedInterfaceProperty(prop))
{
@ -1422,14 +1414,14 @@ void cmTarget::AppendProperty(const char* prop, const char* value,
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
return;
}
if (strcmp(prop, "NAME") == 0)
if (prop == "NAME")
{
cmOStringStream e;
e << "NAME property is read-only\n";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
return;
}
if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0)
if(prop == "INCLUDE_DIRECTORIES")
{
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
@ -1438,7 +1430,7 @@ void cmTarget::AppendProperty(const char* prop, const char* value,
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
return;
}
if(strcmp(prop,"COMPILE_OPTIONS") == 0)
if(prop == "COMPILE_OPTIONS")
{
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
@ -1447,7 +1439,7 @@ void cmTarget::AppendProperty(const char* prop, const char* value,
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
return;
}
if(strcmp(prop,"COMPILE_DEFINITIONS") == 0)
if(prop == "COMPILE_DEFINITIONS")
{
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
@ -1456,7 +1448,7 @@ void cmTarget::AppendProperty(const char* prop, const char* value,
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
return;
}
if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported())
if(prop == "EXPORT_NAME" && this->IsImported())
{
cmOStringStream e;
e << "EXPORT_NAME property can't be set on imported targets (\""
@ -1464,7 +1456,7 @@ void cmTarget::AppendProperty(const char* prop, const char* value,
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
return;
}
if (strcmp(prop, "LINK_LIBRARIES") == 0)
if (prop == "LINK_LIBRARIES")
{
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
@ -2215,7 +2207,7 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list,
}
//----------------------------------------------------------------------------
void cmTarget::MaybeInvalidatePropertyCache(const char* prop)
void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop)
{
// Wipe out maps caching information affected by this property.
if(this->IsImported() && cmHasLiteralPrefix(prop, "IMPORTED"))
@ -2230,8 +2222,8 @@ void cmTarget::MaybeInvalidatePropertyCache(const char* prop)
//----------------------------------------------------------------------------
static void cmTargetCheckLINK_INTERFACE_LIBRARIES(
const char* prop, const char* value, cmMakefile* context, bool imported
)
const std::string& prop, const char* value, cmMakefile* context,
bool imported)
{
// Look for link-type keywords in the value.
static cmsys::RegularExpression
@ -2295,7 +2287,8 @@ static void cmTargetCheckINTERFACE_LINK_LIBRARIES(const char* value,
}
//----------------------------------------------------------------------------
void cmTarget::CheckProperty(const char* prop, cmMakefile* context) const
void cmTarget::CheckProperty(const std::string& prop,
cmMakefile* context) const
{
// Certain properties need checking.
if(cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES"))
@ -2579,7 +2572,7 @@ const char* cmTarget::GetFeature(const char* feature, const char* config) const
}
//----------------------------------------------------------------------------
const char *cmTarget::GetProperty(const char* prop) const
const char *cmTarget::GetProperty(const std::string& prop) const
{
return this->GetProperty(prop, cmProperty::TARGET);
}
@ -2622,14 +2615,9 @@ bool cmTarget::HandleLocationPropertyPolicy() const
}
//----------------------------------------------------------------------------
const char *cmTarget::GetProperty(const char* prop,
const char *cmTarget::GetProperty(const std::string& prop,
cmProperty::ScopeType scope) const
{
if(!prop)
{
return 0;
}
if (this->GetType() == INTERFACE_LIBRARY
&& !whiteListedInterfaceProperty(prop))
{
@ -2640,7 +2628,7 @@ const char *cmTarget::GetProperty(const char* prop,
return 0;
}
if (strcmp(prop, "NAME") == 0)
if (prop == "NAME")
{
return this->GetName();
}
@ -2653,7 +2641,7 @@ const char *cmTarget::GetProperty(const char* prop,
this->GetType() == cmTarget::MODULE_LIBRARY ||
this->GetType() == cmTarget::UNKNOWN_LIBRARY)
{
if(strcmp(prop,"LOCATION") == 0)
if(prop == "LOCATION")
{
if (!this->HandleLocationPropertyPolicy())
{
@ -2680,13 +2668,13 @@ const char *cmTarget::GetProperty(const char* prop,
{
return 0;
}
std::string configName = prop+9;
const char* configName = prop.c_str() + 9;
this->Properties.SetProperty(prop,
this->GetLocation(configName.c_str()),
this->GetLocation(configName),
cmProperty::TARGET);
}
}
if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0)
if(prop == "INCLUDE_DIRECTORIES")
{
static std::string output;
output = "";
@ -2704,7 +2692,7 @@ const char *cmTarget::GetProperty(const char* prop,
}
return output.c_str();
}
if(strcmp(prop,"COMPILE_OPTIONS") == 0)
if(prop == "COMPILE_OPTIONS")
{
static std::string output;
output = "";
@ -2722,7 +2710,7 @@ const char *cmTarget::GetProperty(const char* prop,
}
return output.c_str();
}
if(strcmp(prop,"COMPILE_DEFINITIONS") == 0)
if(prop == "COMPILE_DEFINITIONS")
{
static std::string output;
output = "";
@ -2740,7 +2728,7 @@ const char *cmTarget::GetProperty(const char* prop,
}
return output.c_str();
}
if(strcmp(prop,"LINK_LIBRARIES") == 0)
if(prop == "LINK_LIBRARIES")
{
static std::string output;
output = "";
@ -2757,12 +2745,12 @@ const char *cmTarget::GetProperty(const char* prop,
return output.c_str();
}
if (strcmp(prop,"IMPORTED") == 0)
if (prop == "IMPORTED")
{
return this->IsImported()?"TRUE":"FALSE";
}
if(!strcmp(prop,"SOURCES"))
if(prop == "SOURCES")
{
cmOStringStream ss;
const char* sep = "";
@ -2791,7 +2779,7 @@ const char *cmTarget::GetProperty(const char* prop,
}
// the type property returns what type the target is
if (!strcmp(prop,"TYPE"))
if (prop == "TYPE")
{
return cmTarget::GetTargetTypeName(this->GetType());
}
@ -2806,7 +2794,7 @@ const char *cmTarget::GetProperty(const char* prop,
}
//----------------------------------------------------------------------------
bool cmTarget::GetPropertyAsBool(const char* prop) const
bool cmTarget::GetPropertyAsBool(const std::string& prop) const
{
return cmSystemTools::IsOn(this->GetProperty(prop));
}
@ -3804,7 +3792,7 @@ bool cmTarget::GetImplibGNUtoMS(std::string const& gnuName,
}
//----------------------------------------------------------------------------
void cmTarget::SetPropertyDefault(const char* property,
void cmTarget::SetPropertyDefault(const std::string& property,
const char* default_value)
{
// Compute the name of the variable holding the default value.
@ -4740,7 +4728,7 @@ const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty(
//----------------------------------------------------------------------------
bool isLinkDependentProperty(cmTarget const* tgt, const std::string &p,
const char *interfaceProperty,
const std::string& interfaceProperty,
const char *config)
{
std::vector<cmTarget*> deps;
@ -5984,14 +5972,14 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const
template<typename PropertyType>
PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt,
const std::string prop,
const std::string& prop,
const char *config,
CompatibleType,
PropertyType *);
template<>
bool getLinkInterfaceDependentProperty(cmTarget const* tgt,
const std::string prop,
const std::string& prop,
const char *config,
CompatibleType, bool *)
{
@ -6000,7 +5988,7 @@ bool getLinkInterfaceDependentProperty(cmTarget const* tgt,
template<>
const char * getLinkInterfaceDependentProperty(cmTarget const* tgt,
const std::string prop,
const std::string& prop,
const char *config,
CompatibleType t,
const char **)
@ -6025,7 +6013,7 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt,
template<typename PropertyType>
void checkPropertyConsistency(cmTarget const* depender,
cmTarget const* dependee,
const char *propName,
const cmStdString& propName,
std::set<cmStdString> &emitted,
const char *config,
CompatibleType t,
@ -6135,32 +6123,32 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info,
}
checkPropertyConsistency<bool>(this, li->Target,
"COMPATIBLE_INTERFACE_BOOL",
emittedBools, config, BoolType, 0);
std::string("COMPATIBLE_INTERFACE_BOOL"),
emittedBools, config, BoolType, 0);
if (cmSystemTools::GetErrorOccuredFlag())
{
return;
}
checkPropertyConsistency<const char *>(this, li->Target,
"COMPATIBLE_INTERFACE_STRING",
emittedStrings, config,
StringType, 0);
std::string("COMPATIBLE_INTERFACE_STRING"),
emittedStrings, config,
StringType, 0);
if (cmSystemTools::GetErrorOccuredFlag())
{
return;
}
checkPropertyConsistency<const char *>(this, li->Target,
"COMPATIBLE_INTERFACE_NUMBER_MIN",
emittedMinNumbers, config,
NumberMinType, 0);
std::string("COMPATIBLE_INTERFACE_NUMBER_MIN"),
emittedMinNumbers, config,
NumberMinType, 0);
if (cmSystemTools::GetErrorOccuredFlag())
{
return;
}
checkPropertyConsistency<const char *>(this, li->Target,
"COMPATIBLE_INTERFACE_NUMBER_MAX",
emittedMaxNumbers, config,
NumberMaxType, 0);
std::string("COMPATIBLE_INTERFACE_NUMBER_MAX"),
emittedMaxNumbers, config,
NumberMaxType, 0);
if (cmSystemTools::GetErrorOccuredFlag())
{
return;

View File

@ -223,12 +223,14 @@ public:
void FinishConfigure();
///! Set/Get a property of this target file
void SetProperty(const char *prop, const char *value);
void AppendProperty(const char* prop, const char* value,bool asString=false);
const char *GetProperty(const char *prop) const;
const char *GetProperty(const char *prop, cmProperty::ScopeType scope) const;
bool GetPropertyAsBool(const char *prop) const;
void CheckProperty(const char* prop, cmMakefile* context) const;
void SetProperty(const std::string& prop, const char *value);
void AppendProperty(const std::string& prop, const char* value,
bool asString=false);
const char *GetProperty(const std::string& prop) const;
const char *GetProperty(const std::string& prop,
cmProperty::ScopeType scope) const;
bool GetPropertyAsBool(const std::string& prop) const;
void CheckProperty(const std::string& prop, cmMakefile* context) const;
const char* GetFeature(const char* feature, const char* config) const;
@ -632,7 +634,8 @@ private:
// Use a makefile variable to set a default for the given property.
// If the variable is not defined use the given default instead.
void SetPropertyDefault(const char* property, const char* default_value);
void SetPropertyDefault(const std::string& property,
const char* default_value);
// Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type.
const char* GetOutputTargetType(bool implib) const;
@ -729,7 +732,7 @@ private:
void ClearLinkMaps();
void MaybeInvalidatePropertyCache(const char* prop);
void MaybeInvalidatePropertyCache(const std::string& prop);
void ProcessSourceExpression(std::string const& expr);

View File

@ -16,8 +16,9 @@
//----------------------------------------------------------------------------
bool cmTargetPropCommandBase
::HandleArguments(std::vector<std::string> const& args, const char *prop,
ArgumentFlags flags)
::HandleArguments(std::vector<std::string> const& args,
const std::string& prop,
ArgumentFlags flags)
{
if(args.size() < 2)
{

View File

@ -29,7 +29,8 @@ public:
};
bool HandleArguments(std::vector<std::string> const& args,
const char *prop, ArgumentFlags flags = NO_FLAGS);
const std::string& prop,
ArgumentFlags flags = NO_FLAGS);
cmTypeMacro(cmTargetPropCommandBase, cmCommand);
protected:

View File

@ -54,7 +54,7 @@ void cmTest::SetCommand(std::vector<std::string> const& command)
}
//----------------------------------------------------------------------------
const char *cmTest::GetProperty(const char* prop) const
const char *cmTest::GetProperty(const std::string& prop) const
{
bool chain = false;
const char *retVal =
@ -67,28 +67,20 @@ const char *cmTest::GetProperty(const char* prop) const
}
//----------------------------------------------------------------------------
bool cmTest::GetPropertyAsBool(const char* prop) const
bool cmTest::GetPropertyAsBool(const std::string& prop) const
{
return cmSystemTools::IsOn(this->GetProperty(prop));
}
//----------------------------------------------------------------------------
void cmTest::SetProperty(const char* prop, const char* value)
void cmTest::SetProperty(const std::string& prop, const char* value)
{
if (!prop)
{
return;
}
this->Properties.SetProperty(prop, value, cmProperty::TEST);
}
//----------------------------------------------------------------------------
void cmTest::AppendProperty(const char* prop, const char* value, bool asString)
void cmTest::AppendProperty(const std::string& prop,
const char* value, bool asString)
{
if (!prop)
{
return;
}
this->Properties.AppendProperty(prop, value, cmProperty::TEST, asString);
}

View File

@ -46,10 +46,11 @@ public:
void Print() const;
///! Set/Get a property of this source file
void SetProperty(const char *prop, const char *value);
void AppendProperty(const char* prop, const char* value,bool asString=false);
const char *GetProperty(const char *prop) const;
bool GetPropertyAsBool(const char *prop) const;
void SetProperty(const std::string& prop, const char *value);
void AppendProperty(const std::string& prop,
const char* value,bool asString=false);
const char *GetProperty(const std::string& prop) const;
bool GetPropertyAsBool(const std::string& prop) const;
cmPropertyMap &GetProperties() { return this->Properties; };
/** Get the cmMakefile instance that owns this test. */

View File

@ -2144,7 +2144,8 @@ void cmake::GenerateGraphViz(const char* fileName) const
#endif
}
void cmake::DefineProperty(const char *name, cmProperty::ScopeType scope,
void cmake::DefineProperty(const std::string& name,
cmProperty::ScopeType scope,
const char *ShortDescription,
const char *FullDescription,
bool chained)
@ -2155,7 +2156,7 @@ void cmake::DefineProperty(const char *name, cmProperty::ScopeType scope,
}
cmPropertyDefinition *cmake
::GetPropertyDefinition(const char *name,
::GetPropertyDefinition(const std::string& name,
cmProperty::ScopeType scope)
{
if (this->IsPropertyDefined(name,scope))
@ -2165,25 +2166,22 @@ cmPropertyDefinition *cmake
return 0;
}
bool cmake::IsPropertyDefined(const char *name, cmProperty::ScopeType scope)
bool cmake::IsPropertyDefined(const std::string& name,
cmProperty::ScopeType scope)
{
return this->PropertyDefinitions[scope].IsPropertyDefined(name);
}
bool cmake::IsPropertyChained(const char *name, cmProperty::ScopeType scope)
bool cmake::IsPropertyChained(const std::string& name,
cmProperty::ScopeType scope)
{
return this->PropertyDefinitions[scope].IsPropertyChained(name);
}
void cmake::SetProperty(const char* prop, const char* value)
void cmake::SetProperty(const std::string& prop, const char* value)
{
if (!prop)
{
return;
}
// Special hook to invalidate cached value.
if(strcmp(prop, "DEBUG_CONFIGURATIONS") == 0)
if(prop == "DEBUG_CONFIGURATIONS")
{
this->DebugConfigs.clear();
}
@ -2191,15 +2189,11 @@ void cmake::SetProperty(const char* prop, const char* value)
this->Properties.SetProperty(prop, value, cmProperty::GLOBAL);
}
void cmake::AppendProperty(const char* prop, const char* value, bool asString)
void cmake::AppendProperty(const std::string& prop,
const char* value, bool asString)
{
if (!prop)
{
return;
}
// Special hook to invalidate cached value.
if(strcmp(prop, "DEBUG_CONFIGURATIONS") == 0)
if(prop == "DEBUG_CONFIGURATIONS")
{
this->DebugConfigs.clear();
}
@ -2207,23 +2201,19 @@ void cmake::AppendProperty(const char* prop, const char* value, bool asString)
this->Properties.AppendProperty(prop, value, cmProperty::GLOBAL, asString);
}
const char *cmake::GetProperty(const char* prop)
const char *cmake::GetProperty(const std::string& prop)
{
return this->GetProperty(prop, cmProperty::GLOBAL);
}
const char *cmake::GetProperty(const char* prop, cmProperty::ScopeType scope)
const char *cmake::GetProperty(const std::string& prop,
cmProperty::ScopeType scope)
{
if(!prop)
{
return 0;
}
bool chain = false;
// watch for special properties
std::string propname = prop;
std::string output = "";
if ( propname == "CACHE_VARIABLES" )
if ( prop == "CACHE_VARIABLES" )
{
cmCacheManager::CacheIterator cit =
this->GetCacheManager()->GetCacheIterator();
@ -2237,7 +2227,7 @@ const char *cmake::GetProperty(const char* prop, cmProperty::ScopeType scope)
}
this->SetProperty("CACHE_VARIABLES", output.c_str());
}
else if ( propname == "COMMANDS" )
else if ( prop == "COMMANDS" )
{
cmake::RegisteredCommandsMap::iterator cmds
= this->GetCommands()->begin();
@ -2252,12 +2242,12 @@ const char *cmake::GetProperty(const char* prop, cmProperty::ScopeType scope)
}
this->SetProperty("COMMANDS",output.c_str());
}
else if ( propname == "IN_TRY_COMPILE" )
else if ( prop == "IN_TRY_COMPILE" )
{
this->SetProperty("IN_TRY_COMPILE",
this->GetIsInTryCompile()? "1":"0");
}
else if ( propname == "ENABLED_LANGUAGES" )
else if ( prop == "ENABLED_LANGUAGES" )
{
std::string lang;
if(this->GlobalGenerator)
@ -2278,7 +2268,7 @@ const char *cmake::GetProperty(const char* prop, cmProperty::ScopeType scope)
return this->Properties.GetPropertyValue(prop, scope, chain);
}
bool cmake::GetPropertyAsBool(const char* prop)
bool cmake::GetPropertyAsBool(const std::string& prop)
{
return cmSystemTools::IsOn(this->GetProperty(prop));
}

View File

@ -269,11 +269,13 @@ class cmake
void GetGeneratorDocumentation(std::vector<cmDocumentationEntry>&);
///! Set/Get a property of this target file
void SetProperty(const char *prop, const char *value);
void AppendProperty(const char *prop, const char *value,bool asString=false);
const char *GetProperty(const char *prop);
const char *GetProperty(const char *prop, cmProperty::ScopeType scope);
bool GetPropertyAsBool(const char *prop);
void SetProperty(const std::string& prop, const char *value);
void AppendProperty(const std::string& prop,
const char *value,bool asString=false);
const char *GetProperty(const std::string& prop);
const char *GetProperty(const std::string& prop,
cmProperty::ScopeType scope);
bool GetPropertyAsBool(const std::string& prop);
// Get the properties
cmPropertyMap &GetProperties() { return this->Properties; };
@ -317,18 +319,18 @@ class cmake
void MarkCliAsUsed(const std::string& variable);
// Define a property
void DefineProperty(const char *name, cmProperty::ScopeType scope,
void DefineProperty(const std::string& name, cmProperty::ScopeType scope,
const char *ShortDescription,
const char *FullDescription,
bool chain = false);
// get property definition
cmPropertyDefinition *GetPropertyDefinition
(const char *name, cmProperty::ScopeType scope);
(const std::string& name, cmProperty::ScopeType scope);
// Is a property defined?
bool IsPropertyDefined(const char *name, cmProperty::ScopeType scope);
bool IsPropertyChained(const char *name, cmProperty::ScopeType scope);
bool IsPropertyDefined(const std::string& name, cmProperty::ScopeType scope);
bool IsPropertyChained(const std::string& name, cmProperty::ScopeType scope);
/** Get the list of configurations (in upper case) considered to be
debugging configurations.*/