summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2013-09-02 20:27:32 (GMT)
committerBrad King <brad.king@kitware.com>2014-03-08 18:05:28 (GMT)
commitec97ed7d0c67b635caf3ada65541b2eaf0818a93 (patch)
tree9b38ed2ca59f7da24dfc0db503d9e203ed265fb4
parent2977330a7b27d21e2b6276d9386624b6811b9274 (diff)
downloadCMake-ec97ed7d0c67b635caf3ada65541b2eaf0818a93.zip
CMake-ec97ed7d0c67b635caf3ada65541b2eaf0818a93.tar.gz
CMake-ec97ed7d0c67b635caf3ada65541b2eaf0818a93.tar.bz2
stringapi: Use strings for property names
Property names are always generated by CMake and should never be NULL.
-rw-r--r--Source/cmCacheManager.cxx34
-rw-r--r--Source/cmCacheManager.h18
-rw-r--r--Source/cmExportFileGenerator.cxx15
-rw-r--r--Source/cmExportFileGenerator.h8
-rw-r--r--Source/cmExportTryCompileFileGenerator.cxx5
-rw-r--r--Source/cmExportTryCompileFileGenerator.h2
-rw-r--r--Source/cmGeneratorTarget.cxx4
-rw-r--r--Source/cmGeneratorTarget.h4
-rw-r--r--Source/cmGetTargetPropertyCommand.cxx12
-rw-r--r--Source/cmLocalGenerator.cxx16
-rw-r--r--Source/cmLocalGenerator.h4
-rw-r--r--Source/cmMakefile.cxx89
-rw-r--r--Source/cmMakefile.h16
-rw-r--r--Source/cmProperty.cxx5
-rw-r--r--Source/cmProperty.h5
-rw-r--r--Source/cmPropertyDefinition.cxx2
-rw-r--r--Source/cmPropertyDefinition.h2
-rw-r--r--Source/cmPropertyDefinitionMap.cxx21
-rw-r--r--Source/cmPropertyDefinitionMap.h6
-rw-r--r--Source/cmPropertyMap.cxx16
-rw-r--r--Source/cmPropertyMap.h8
-rw-r--r--Source/cmQtAutoGenerators.cxx2
-rw-r--r--Source/cmSourceFile.cxx25
-rw-r--r--Source/cmSourceFile.h11
-rw-r--r--Source/cmTarget.cxx118
-rw-r--r--Source/cmTarget.h19
-rw-r--r--Source/cmTargetPropCommandBase.cxx5
-rw-r--r--Source/cmTargetPropCommandBase.h3
-rw-r--r--Source/cmTest.cxx18
-rw-r--r--Source/cmTest.h9
-rw-r--r--Source/cmake.cxx50
-rw-r--r--Source/cmake.h20
32 files changed, 262 insertions, 310 deletions
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index 9e0064e..04542d8 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -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;
}
diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h
index f487e8e..ac6187b 100644
--- a/Source/cmCacheManager.h
+++ b/Source/cmCacheManager.h
@@ -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*);
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 4a161ee..79566a9 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -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
diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h
index 57ab378..326fe36 100644
--- a/Source/cmExportFileGenerator.h
+++ b/Source/cmExportFileGenerator.h
@@ -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,
diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx
index a8a91d6..fe8c8ec 100644
--- a/Source/cmExportTryCompileFileGenerator.cxx
+++ b/Source/cmExportTryCompileFileGenerator.cxx
@@ -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);
diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h
index 71ac0dd..a16fe6b 100644
--- a/Source/cmExportTryCompileFileGenerator.h
+++ b/Source/cmExportTryCompileFileGenerator.h
@@ -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);
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index a7b2fb6..d9885b9 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -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);
}
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 1e6ce64..6e19f7d 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -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;
diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx
index 4aa49fe..b64f847 100644
--- a/Source/cmGetTargetPropertyCommand.cxx
+++ b/Source/cmGetTargetPropertyCommand.cxx
@@ -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());
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index b86a956..5bfd9da 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -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);
}
}
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 2e05804..888611d 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -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
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 556e7a4..0fce1f4 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -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
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 45f3b9f..5f4b803 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -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
diff --git a/Source/cmProperty.cxx b/Source/cmProperty.cxx
index 3b37cf3..40976db 100644
--- a/Source/cmProperty.cxx
+++ b/Source/cmProperty.cxx
@@ -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)
diff --git a/Source/cmProperty.h b/Source/cmProperty.h
index bb75bb0..789be1d 100644
--- a/Source/cmProperty.h
+++ b/Source/cmProperty.h
@@ -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;
diff --git a/Source/cmPropertyDefinition.cxx b/Source/cmPropertyDefinition.cxx
index abc57ce..1af967c 100644
--- a/Source/cmPropertyDefinition.cxx
+++ b/Source/cmPropertyDefinition.cxx
@@ -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)
diff --git a/Source/cmPropertyDefinition.h b/Source/cmPropertyDefinition.h
index 1b6a7a6..9ca8222 100644
--- a/Source/cmPropertyDefinition.h
+++ b/Source/cmPropertyDefinition.h
@@ -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);
diff --git a/Source/cmPropertyDefinitionMap.cxx b/Source/cmPropertyDefinitionMap.cxx
index db29504..9ebbaa4 100644
--- a/Source/cmPropertyDefinitionMap.cxx
+++ b/Source/cmPropertyDefinitionMap.cxx
@@ -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())
{
diff --git a/Source/cmPropertyDefinitionMap.h b/Source/cmPropertyDefinitionMap.h
index 736e243..68c3ff3 100644
--- a/Source/cmPropertyDefinitionMap.h
+++ b/Source/cmPropertyDefinitionMap.h
@@ -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
diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx
index e94e3e9..e335b3b 100644
--- a/Source/cmPropertyMap.cxx
+++ b/Source/cmPropertyMap.cxx
@@ -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;
}
diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h
index 0c3aad4..a13ac35 100644
--- a/Source/cmPropertyMap.h
+++ b/Source/cmPropertyMap.h
@@ -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;
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index dfb310e..7d0ce5f 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -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)
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index 23422a2..dd95f23 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -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));
}
diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h
index 4440b05..85d6332 100644
--- a/Source/cmSourceFile.h
+++ b/Source/cmSourceFile.h
@@ -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
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 1c2b27a..fc2ab25 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -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;
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 471ea94..f0dd708 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -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);
diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx
index 195690e..2a20516 100644
--- a/Source/cmTargetPropCommandBase.cxx
+++ b/Source/cmTargetPropCommandBase.cxx
@@ -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)
{
diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h
index c402836..555a08a 100644
--- a/Source/cmTargetPropCommandBase.h
+++ b/Source/cmTargetPropCommandBase.h
@@ -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:
diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx
index 9cda978..4ff71ac 100644
--- a/Source/cmTest.cxx
+++ b/Source/cmTest.cxx
@@ -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);
}
diff --git a/Source/cmTest.h b/Source/cmTest.h
index 1fe8fc0..1becbf7 100644
--- a/Source/cmTest.h
+++ b/Source/cmTest.h
@@ -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. */
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index abbabe7..149e299 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -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));
}
diff --git a/Source/cmake.h b/Source/cmake.h
index dfec55c..e89868c 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -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.*/