summaryrefslogtreecommitdiffstats
path: root/Source/cmTarget.cxx
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 /Source/cmTarget.cxx
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.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r--Source/cmTarget.cxx118
1 files changed, 53 insertions, 65 deletions
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;