summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitaly Stakhovsky <vvs31415@gitlab.org>2020-09-03 15:30:00 (GMT)
committervvs31415 <vvs31415@users.noreply.github.com>2020-09-03 15:36:54 (GMT)
commit1380b4376408a1ec97bc23f521c067a83dc58680 (patch)
treee51d8351d2b61d08a6798fa3a71578c75fba458d
parentca5babfd7a1da8e32f927ad086fdd91c2b09853b (diff)
downloadCMake-1380b4376408a1ec97bc23f521c067a83dc58680.zip
CMake-1380b4376408a1ec97bc23f521c067a83dc58680.tar.gz
CMake-1380b4376408a1ec97bc23f521c067a83dc58680.tar.bz2
Refactor: Use cmToCStr()
-rw-r--r--Source/cmCPluginAPI.cxx4
-rw-r--r--Source/cmGeneratorTarget.cxx14
-rw-r--r--Source/cmGetDirectoryPropertyCommand.cxx4
-rw-r--r--Source/cmGetPropertyCommand.cxx9
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx3
-rw-r--r--Source/cmLocalNinjaGenerator.cxx3
-rw-r--r--Source/cmMakefile.cxx12
-rw-r--r--Source/cmQTWrapCPPCommand.cxx2
-rw-r--r--Source/cmStateSnapshot.cxx3
-rw-r--r--Source/cmTarget.cxx2
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx2
11 files changed, 23 insertions, 35 deletions
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index 1a1bbec..ee2960b 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -581,13 +581,13 @@ const char* CCONV cmSourceFileGetProperty(void* arg, const char* prop)
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
if (cmSourceFile* rsf = sf->RealSourceFile) {
cmProp p = rsf->GetProperty(prop);
- return p ? p->c_str() : nullptr;
+ return cmToCStr(p);
}
if (!strcmp(prop, "LOCATION")) {
return sf->FullPath.c_str();
}
cmProp retVal = sf->Properties.GetPropertyValue(prop);
- return retVal ? retVal->c_str() : nullptr;
+ return cmToCStr(retVal);
}
int CCONV cmSourceFileGetPropertyAsBool(void* arg, const char* prop)
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 05c8cc8..b75aa63 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -4775,12 +4775,11 @@ cmGeneratorTarget::Names cmGeneratorTarget::GetLibraryNames(
// The library's soname.
this->ComputeVersionedName(targetNames.SharedObject, prefix,
targetNames.Base, suffix, targetNames.Output,
- (soversion ? soversion->c_str() : nullptr));
+ cmToCStr(soversion));
// The library's real name on disk.
this->ComputeVersionedName(targetNames.Real, prefix, targetNames.Base,
- suffix, targetNames.Output,
- (version ? version->c_str() : nullptr));
+ suffix, targetNames.Output, cmToCStr(version));
}
// The import library name.
@@ -4816,10 +4815,7 @@ cmGeneratorTarget::Names cmGeneratorTarget::GetExecutableNames(
const char* version = nullptr;
#else
// Check for executable version properties.
- const char* version = nullptr;
- if (cmProp p = this->GetProperty("VERSION")) {
- version = p->c_str();
- }
+ const char* version = cmToCStr(this->GetProperty("VERSION"));
if (this->GetType() != cmStateEnums::EXECUTABLE ||
this->Makefile->IsOn("XCODE")) {
version = nullptr;
@@ -5536,7 +5532,7 @@ const char* getTypedProperty<const char*>(
cmProp value = tgt->GetProperty(prop);
if (genexInterpreter == nullptr) {
- return value ? value->c_str() : nullptr;
+ return cmToCStr(value);
}
return genexInterpreter->Evaluate(value ? *value : "", prop).c_str();
@@ -5550,7 +5546,7 @@ std::string getTypedProperty<std::string>(
cmProp value = tgt->GetProperty(prop);
if (genexInterpreter == nullptr) {
- return valueAsString(value ? value->c_str() : nullptr);
+ return valueAsString(cmToCStr(value));
}
return genexInterpreter->Evaluate(value ? *value : "", prop);
diff --git a/Source/cmGetDirectoryPropertyCommand.cxx b/Source/cmGetDirectoryPropertyCommand.cxx
index fa4a40b..c2098c0 100644
--- a/Source/cmGetDirectoryPropertyCommand.cxx
+++ b/Source/cmGetDirectoryPropertyCommand.cxx
@@ -86,9 +86,7 @@ bool cmGetDirectoryPropertyCommand(std::vector<std::string> const& args,
break;
}
}
- if (cmProp p = dir->GetProperty(*i)) {
- prop = p->c_str();
- }
+ prop = cmToCStr(dir->GetProperty(*i));
}
StoreResult(status.GetMakefile(), variable, prop);
return true;
diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx
index 7f60f85..3a5b39d 100644
--- a/Source/cmGetPropertyCommand.cxx
+++ b/Source/cmGetPropertyCommand.cxx
@@ -281,8 +281,7 @@ bool HandleGlobalMode(cmExecutionStatus& status, const std::string& name,
// Get the property.
cmake* cm = status.GetMakefile().GetCMakeInstance();
cmProp p = cm->GetState()->GetGlobalProperty(propertyName);
- return StoreResult(infoType, status.GetMakefile(), variable,
- p ? p->c_str() : nullptr);
+ return StoreResult(infoType, status.GetMakefile(), variable, cmToCStr(p));
}
bool HandleDirectoryMode(cmExecutionStatus& status, const std::string& name,
@@ -329,8 +328,7 @@ bool HandleDirectoryMode(cmExecutionStatus& status, const std::string& name,
// Get the property.
cmProp p = mf->GetProperty(propertyName);
- return StoreResult(infoType, status.GetMakefile(), variable,
- p ? p->c_str() : nullptr);
+ return StoreResult(infoType, status.GetMakefile(), variable, cmToCStr(p));
}
bool HandleTargetMode(cmExecutionStatus& status, const std::string& name,
@@ -449,8 +447,7 @@ bool HandleCacheMode(cmExecutionStatus& status, const std::string& name,
value = status.GetMakefile().GetState()->GetCacheEntryProperty(
name, propertyName);
}
- StoreResult(infoType, status.GetMakefile(), variable,
- value ? value->c_str() : nullptr);
+ StoreResult(infoType, status.GetMakefile(), variable, cmToCStr(value));
return true;
}
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 73a2caa..84cfaeb 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -381,8 +381,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
std::string location = *expath;
cmProp p = target->GetProperty("VS_PROJECT_TYPE");
- this->WriteExternalProject(fout, project, location,
- p ? p->c_str() : nullptr,
+ this->WriteExternalProject(fout, project, location, cmToCStr(p),
target->GetUtilities());
written = true;
} else {
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index 2188d7f..ad782ee 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -363,8 +363,7 @@ void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os)
{
cmGlobalNinjaGenerator::WriteDivider(os);
os << "# Write statements declared in CMakeLists.txt:\n"
- << "# "
- << cmToCStr(this->Makefile->GetDefinition("CMAKE_CURRENT_LIST_FILE"))
+ << "# " << this->Makefile->GetSafeDefinition("CMAKE_CURRENT_LIST_FILE")
<< '\n';
if (this->IsRootMakefile()) {
os << "# Which is the root file.\n";
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index f384e21..8097dd1 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1430,31 +1430,31 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent)
{
const char* prop = "IMPLICIT_DEPENDS_INCLUDE_TRANSFORM";
cmProp p = parent->GetProperty(prop);
- this->SetProperty(prop, p ? p->c_str() : nullptr);
+ this->SetProperty(prop, cmToCStr(p));
}
// compile definitions property and per-config versions
cmPolicies::PolicyStatus polSt = this->GetPolicyStatus(cmPolicies::CMP0043);
if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) {
cmProp p = parent->GetProperty("COMPILE_DEFINITIONS");
- this->SetProperty("COMPILE_DEFINITIONS", p ? p->c_str() : nullptr);
+ this->SetProperty("COMPILE_DEFINITIONS", cmToCStr(p));
std::vector<std::string> configs =
this->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig);
for (std::string const& config : configs) {
std::string defPropName =
cmStrCat("COMPILE_DEFINITIONS_", cmSystemTools::UpperCase(config));
cmProp prop = parent->GetProperty(defPropName);
- this->SetProperty(defPropName, prop ? prop->c_str() : nullptr);
+ this->SetProperty(defPropName, cmToCStr(prop));
}
}
// labels
cmProp p = parent->GetProperty("LABELS");
- this->SetProperty("LABELS", p ? p->c_str() : nullptr);
+ this->SetProperty("LABELS", cmToCStr(p));
// link libraries
p = parent->GetProperty("LINK_LIBRARIES");
- this->SetProperty("LINK_LIBRARIES", p ? p->c_str() : nullptr);
+ this->SetProperty("LINK_LIBRARIES", cmToCStr(p));
// the initial project name
this->StateSnapshot.SetProjectName(parent->StateSnapshot.GetProjectName());
@@ -2684,7 +2684,7 @@ cmProp cmMakefile::GetDefinition(const std::string& name) const
vv->VariableAccessed(name,
def ? cmVariableWatch::VARIABLE_READ_ACCESS
: cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS,
- (def ? def->c_str() : nullptr), this);
+ cmToCStr(def), this);
if (watch_function_executed) {
// A callback was executed and may have caused re-allocation of the
diff --git a/Source/cmQTWrapCPPCommand.cxx b/Source/cmQTWrapCPPCommand.cxx
index 795c2ee..de462db 100644
--- a/Source/cmQTWrapCPPCommand.cxx
+++ b/Source/cmQTWrapCPPCommand.cxx
@@ -41,7 +41,7 @@ bool cmQTWrapCPPCommand(std::vector<std::string> const& args,
cmSourceFile* sf = mf.GetOrCreateSource(newName, true);
if (curr) {
cmProp p = curr->GetProperty("ABSTRACT");
- sf->SetProperty("ABSTRACT", p ? p->c_str() : nullptr);
+ sf->SetProperty("ABSTRACT", cmToCStr(p));
}
// Compute the name of the header from which to generate the file.
diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx
index bf8e331..3fcf61c 100644
--- a/Source/cmStateSnapshot.cxx
+++ b/Source/cmStateSnapshot.cxx
@@ -411,8 +411,7 @@ void cmStateSnapshot::InitializeFromParent()
parent->BuildSystemDirectory->Properties.GetPropertyValue(
"INCLUDE_REGULAR_EXPRESSION");
this->Position->BuildSystemDirectory->Properties.SetProperty(
- "INCLUDE_REGULAR_EXPRESSION",
- include_regex ? include_regex->c_str() : nullptr);
+ "INCLUDE_REGULAR_EXPRESSION", cmToCStr(include_regex));
}
cmState* cmStateSnapshot::GetState() const
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index ba648b7..7e8e931 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -1330,7 +1330,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
cmStrCat(reusedFrom, ".dir/"));
cmProp tmp = reusedTarget->GetProperty("COMPILE_PDB_NAME");
- this->SetProperty("COMPILE_PDB_NAME", tmp ? tmp->c_str() : nullptr);
+ this->SetProperty("COMPILE_PDB_NAME", cmToCStr(tmp));
this->AddUtility(reusedFrom, false, impl->Makefile);
} else if (prop == propC_STANDARD || prop == propCXX_STANDARD ||
prop == propCUDA_STANDARD || prop == propOBJC_STANDARD ||
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index dc61def..0b2b5d9 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -515,7 +515,7 @@ void cmVisualStudio10TargetGenerator::Generate()
p = this->GeneratorTarget->GetProperty(
"DOTNET_TARGET_FRAMEWORK_VERSION");
}
- const char* targetFrameworkVersion = p ? p->c_str() : nullptr;
+ const char* targetFrameworkVersion = cmToCStr(p);
if (!targetFrameworkVersion && this->ProjectType == csproj &&
this->GlobalGenerator->TargetsWindowsCE() &&
this->GlobalGenerator->GetVersion() ==