mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-26 04:09:35 +03:00
Refactor: Use cmToCStr()
This commit is contained in:
committed by
vvs31415
parent
ca5babfd7a
commit
1380b43764
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
+1
-1
@@ -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 ||
|
||||
|
||||
@@ -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() ==
|
||||
|
||||
Reference in New Issue
Block a user