AppendProperty: convert value param to std::string

This commit is contained in:
Vitaly Stakhovsky
2020-01-25 10:37:00 -05:00
parent 33e7bd66c0
commit 1398517f31
21 changed files with 98 additions and 110 deletions

View File

@@ -648,8 +648,8 @@ void cmCacheManager::CacheEntry::AppendProperty(const std::string& prop,
bool asString)
{
if (prop == "TYPE") {
this->Type = cmState::StringToCacheEntryType(!value.empty() ? value.c_str()
: "STRING");
this->Type =
cmState::StringToCacheEntryType(!value.empty() ? value : "STRING");
} else if (prop == "VALUE") {
if (!value.empty()) {
if (!this->Value.empty() && !asString) {
@@ -658,7 +658,7 @@ void cmCacheManager::CacheEntry::AppendProperty(const std::string& prop,
this->Value += value;
}
} else {
this->Properties.AppendProperty(prop, value.c_str(), asString);
this->Properties.AppendProperty(prop, value, asString);
}
}

View File

@@ -1645,7 +1645,9 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
for (std::string const& c : configs) {
std::string defPropName =
cmStrCat("COMPILE_DEFINITIONS_", cmSystemTools::UpperCase(c));
t->AppendProperty(defPropName, mf->GetProperty(defPropName));
if (const char* val = mf->GetProperty(defPropName)) {
t->AppendProperty(defPropName, val);
}
}
}
}

View File

@@ -32,7 +32,7 @@ bool cmLinkLibrariesCommand(std::vector<std::string> const& args,
}
mf.AppendProperty("LINK_LIBRARIES", "optimized");
}
mf.AppendProperty("LINK_LIBRARIES", i->c_str());
mf.AppendProperty("LINK_LIBRARIES", *i);
}
return true;

View File

@@ -167,7 +167,7 @@ bool cmMacroFunctionBlocker::Replay(std::vector<cmListFileFunction> functions,
cmExecutionStatus& status)
{
cmMakefile& mf = status.GetMakefile();
mf.AppendProperty("MACROS", this->Args[0].c_str());
mf.AppendProperty("MACROS", this->Args[0]);
// create a new command and add it to cmake
cmMacroHelperCommand f;
f.Args = this->Args;

View File

@@ -1288,17 +1288,17 @@ void cmMakefile::RemoveDefineFlag(std::string const& flag)
void cmMakefile::AddCompileDefinition(std::string const& option)
{
this->AppendProperty("COMPILE_DEFINITIONS", option.c_str());
this->AppendProperty("COMPILE_DEFINITIONS", option);
}
void cmMakefile::AddCompileOption(std::string const& option)
{
this->AppendProperty("COMPILE_OPTIONS", option.c_str());
this->AppendProperty("COMPILE_OPTIONS", option);
}
void cmMakefile::AddLinkOption(std::string const& option)
{
this->AppendProperty("LINK_OPTIONS", option.c_str());
this->AppendProperty("LINK_OPTIONS", option);
}
void cmMakefile::AddLinkDirectory(std::string const& directory, bool before)
@@ -4039,8 +4039,8 @@ void cmMakefile::SetProperty(const std::string& prop, const char* value)
this->StateSnapshot.GetDirectory().SetProperty(prop, value, this->Backtrace);
}
void cmMakefile::AppendProperty(const std::string& prop, const char* value,
bool asString)
void cmMakefile::AppendProperty(const std::string& prop,
const std::string& value, bool asString)
{
this->StateSnapshot.GetDirectory().AppendProperty(prop, value, asString,
this->Backtrace);

View File

@@ -784,7 +784,7 @@ public:
//! Set/Get a property of this directory
void SetProperty(const std::string& prop, const char* value);
void AppendProperty(const std::string& prop, const char* value,
void AppendProperty(const std::string& prop, const std::string& value,
bool asString = false);
const char* GetProperty(const std::string& prop) const;
const char* GetProperty(const std::string& prop, bool chain) const;

View File

@@ -20,11 +20,11 @@ void cmPropertyMap::SetProperty(const std::string& name, const char* value)
Map_[name] = value;
}
void cmPropertyMap::AppendProperty(const std::string& name, const char* value,
bool asString)
void cmPropertyMap::AppendProperty(const std::string& name,
const std::string& value, bool asString)
{
// Skip if nothing to append.
if (!value || !*value) {
if (value.empty()) {
return;
}

View File

@@ -27,7 +27,7 @@ public:
void SetProperty(const std::string& name, const char* value);
//! Append to the property value
void AppendProperty(const std::string& name, const char* value,
void AppendProperty(const std::string& name, const std::string& value,
bool asString = false);
//! Get the property value

View File

@@ -194,9 +194,8 @@ namespace {
bool HandleGlobalMode(cmExecutionStatus& status,
const std::set<std::string>& names,
const std::string& propertyName,
const std::string& propertyValue,
const bool appendAsString, const bool appendMode,
const bool remove)
const std::string& propertyValue, bool appendAsString,
bool appendMode, bool remove)
{
if (!names.empty()) {
status.SetError("given names for GLOBAL scope.");
@@ -205,14 +204,14 @@ bool HandleGlobalMode(cmExecutionStatus& status,
// Set or append the property.
cmake* cm = status.GetMakefile().GetCMakeInstance();
const char* value = propertyValue.c_str();
if (remove) {
value = nullptr;
}
if (appendMode) {
cm->AppendProperty(propertyName, value ? value : "", appendAsString);
cm->AppendProperty(propertyName, propertyValue, appendAsString);
} else {
cm->SetProperty(propertyName, value);
if (remove) {
cm->SetProperty(propertyName, nullptr);
} else {
cm->SetProperty(propertyName, propertyValue.c_str());
}
}
return true;
@@ -221,9 +220,8 @@ bool HandleGlobalMode(cmExecutionStatus& status,
bool HandleDirectoryMode(cmExecutionStatus& status,
const std::set<std::string>& names,
const std::string& propertyName,
const std::string& propertyValue,
const bool appendAsString, const bool appendMode,
const bool remove)
const std::string& propertyValue, bool appendAsString,
bool appendMode, bool remove)
{
if (names.size() > 1) {
status.SetError("allows at most one name for DIRECTORY scope.");
@@ -258,14 +256,14 @@ bool HandleDirectoryMode(cmExecutionStatus& status,
}
// Set or append the property.
const char* value = propertyValue.c_str();
if (remove) {
value = nullptr;
}
if (appendMode) {
mf->AppendProperty(propertyName, value ? value : "", appendAsString);
mf->AppendProperty(propertyName, propertyValue, appendAsString);
} else {
mf->SetProperty(propertyName, value);
if (remove) {
mf->SetProperty(propertyName, nullptr);
} else {
mf->SetProperty(propertyName, propertyValue.c_str());
}
}
return true;
@@ -274,9 +272,8 @@ bool HandleDirectoryMode(cmExecutionStatus& status,
bool HandleTargetMode(cmExecutionStatus& status,
const std::set<std::string>& names,
const std::string& propertyName,
const std::string& propertyValue,
const bool appendAsString, const bool appendMode,
const bool remove)
const std::string& propertyValue, bool appendAsString,
bool appendMode, bool remove)
{
for (std::string const& name : names) {
if (status.GetMakefile().IsAlias(name)) {
@@ -300,18 +297,18 @@ bool HandleTargetMode(cmExecutionStatus& status,
bool HandleTarget(cmTarget* target, cmMakefile& makefile,
const std::string& propertyName,
const std::string& propertyValue, const bool appendAsString,
const bool appendMode, const bool remove)
const std::string& propertyValue, bool appendAsString,
bool appendMode, bool remove)
{
// Set or append the property.
const char* value = propertyValue.c_str();
if (remove) {
value = nullptr;
}
if (appendMode) {
target->AppendProperty(propertyName, value, appendAsString);
target->AppendProperty(propertyName, propertyValue, appendAsString);
} else {
target->SetProperty(propertyName, value);
if (remove) {
target->SetProperty(propertyName, nullptr);
} else {
target->SetProperty(propertyName, propertyValue.c_str());
}
}
// Check the resulting value.
@@ -323,9 +320,8 @@ bool HandleTarget(cmTarget* target, cmMakefile& makefile,
bool HandleSourceMode(cmExecutionStatus& status,
const std::set<std::string>& names,
const std::string& propertyName,
const std::string& propertyValue,
const bool appendAsString, const bool appendMode,
const bool remove)
const std::string& propertyValue, bool appendAsString,
bool appendMode, bool remove)
{
for (std::string const& name : names) {
// Get the source file.
@@ -344,28 +340,26 @@ bool HandleSourceMode(cmExecutionStatus& status,
}
bool HandleSource(cmSourceFile* sf, const std::string& propertyName,
const std::string& propertyValue, const bool appendAsString,
const bool appendMode, const bool remove)
const std::string& propertyValue, bool appendAsString,
bool appendMode, bool remove)
{
// Set or append the property.
const char* value = propertyValue.c_str();
if (remove) {
value = nullptr;
}
if (appendMode) {
sf->AppendProperty(propertyName, value, appendAsString);
sf->AppendProperty(propertyName, propertyValue, appendAsString);
} else {
sf->SetProperty(propertyName, value);
if (remove) {
sf->SetProperty(propertyName, nullptr);
} else {
sf->SetProperty(propertyName, propertyValue.c_str());
}
}
return true;
}
bool HandleTestMode(cmExecutionStatus& status, std::set<std::string>& names,
const std::string& propertyName,
const std::string& propertyValue,
const bool appendAsString, const bool appendMode,
const bool remove)
const std::string& propertyValue, bool appendAsString,
bool appendMode, bool remove)
{
// Look for tests with all names given.
std::set<std::string>::iterator next;
@@ -396,18 +390,18 @@ bool HandleTestMode(cmExecutionStatus& status, std::set<std::string>& names,
}
bool HandleTest(cmTest* test, const std::string& propertyName,
const std::string& propertyValue, const bool appendAsString,
const bool appendMode, const bool remove)
const std::string& propertyValue, bool appendAsString,
bool appendMode, bool remove)
{
// Set or append the property.
const char* value = propertyValue.c_str();
if (remove) {
value = nullptr;
}
if (appendMode) {
test->AppendProperty(propertyName, value, appendAsString);
test->AppendProperty(propertyName, propertyValue, appendAsString);
} else {
test->SetProperty(propertyName, value);
if (remove) {
test->SetProperty(propertyName, nullptr);
} else {
test->SetProperty(propertyName, propertyValue.c_str());
}
}
return true;
@@ -416,9 +410,8 @@ bool HandleTest(cmTest* test, const std::string& propertyName,
bool HandleCacheMode(cmExecutionStatus& status,
const std::set<std::string>& names,
const std::string& propertyName,
const std::string& propertyValue,
const bool appendAsString, const bool appendMode,
const bool remove)
const std::string& propertyValue, bool appendAsString,
bool appendMode, bool remove)
{
if (propertyName == "ADVANCED") {
if (!remove && !cmIsOn(propertyValue) && !cmIsOff(propertyValue)) {
@@ -463,9 +456,8 @@ bool HandleCacheMode(cmExecutionStatus& status,
bool HandleCacheEntry(std::string const& cacheKey, const cmMakefile& makefile,
const std::string& propertyName,
const std::string& propertyValue,
const bool appendAsString, const bool appendMode,
const bool remove)
const std::string& propertyValue, bool appendAsString,
bool appendMode, bool remove)
{
// Set or append the property.
const char* value = propertyValue.c_str();
@@ -486,9 +478,8 @@ bool HandleCacheEntry(std::string const& cacheKey, const cmMakefile& makefile,
bool HandleInstallMode(cmExecutionStatus& status,
const std::set<std::string>& names,
const std::string& propertyName,
const std::string& propertyValue,
const bool appendAsString, const bool appendMode,
const bool remove)
const std::string& propertyValue, bool appendAsString,
bool appendMode, bool remove)
{
cmake* cm = status.GetMakefile().GetCMakeInstance();
@@ -510,8 +501,8 @@ bool HandleInstallMode(cmExecutionStatus& status,
bool HandleInstall(cmInstalledFile* file, cmMakefile& makefile,
const std::string& propertyName,
const std::string& propertyValue, const bool appendAsString,
const bool appendMode, const bool remove)
const std::string& propertyValue, bool appendAsString,
bool appendMode, bool remove)
{
// Set or append the property.
const char* value = propertyValue.c_str();

View File

@@ -260,21 +260,21 @@ void cmSourceFile::SetProperty(const std::string& prop, const char* value)
}
}
void cmSourceFile::AppendProperty(const std::string& prop, const char* value,
bool asString)
void cmSourceFile::AppendProperty(const std::string& prop,
const std::string& value, bool asString)
{
if (prop == propINCLUDE_DIRECTORIES) {
if (value && *value) {
if (!value.empty()) {
cmListFileBacktrace lfbt = this->Location.GetMakefile()->GetBacktrace();
this->IncludeDirectories.emplace_back(value, lfbt);
}
} else if (prop == propCOMPILE_OPTIONS) {
if (value && *value) {
if (!value.empty()) {
cmListFileBacktrace lfbt = this->Location.GetMakefile()->GetBacktrace();
this->CompileOptions.emplace_back(value, lfbt);
}
} else if (prop == propCOMPILE_DEFINITIONS) {
if (value && *value) {
if (!value.empty()) {
cmListFileBacktrace lfbt = this->Location.GetMakefile()->GetBacktrace();
this->CompileDefinitions.emplace_back(value, lfbt);
}

View File

@@ -42,7 +42,7 @@ public:
//! Set/Get a property of this source file
void SetProperty(const std::string& prop, const char* value);
void AppendProperty(const std::string& prop, const char* value,
void AppendProperty(const std::string& prop, const std::string& value,
bool asString = false);
//! Might return a nullptr if the property is not set or invalid
const char* GetProperty(const std::string& prop) const;

View File

@@ -557,8 +557,8 @@ void cmState::SetGlobalProperty(const std::string& prop, const char* value)
this->GlobalProperties.SetProperty(prop, value);
}
void cmState::AppendGlobalProperty(const std::string& prop, const char* value,
bool asString)
void cmState::AppendGlobalProperty(const std::string& prop,
const std::string& value, bool asString)
{
this->GlobalProperties.AppendProperty(prop, value, asString);
}

View File

@@ -168,7 +168,7 @@ public:
std::vector<std::string> GetCommandNames() const;
void SetGlobalProperty(const std::string& prop, const char* value);
void AppendGlobalProperty(const std::string& prop, const char* value,
void AppendGlobalProperty(const std::string& prop, const std::string& value,
bool asString = false);
const char* GetGlobalProperty(const std::string& prop);
bool GetGlobalPropertyAsBool(const std::string& prop);

View File

@@ -521,7 +521,7 @@ void cmStateDirectory::SetProperty(const std::string& prop, const char* value,
}
void cmStateDirectory::AppendProperty(const std::string& prop,
const char* value, bool asString,
const std::string& value, bool asString,
cmListFileBacktrace const& lfbt)
{
if (prop == "INCLUDE_DIRECTORIES") {

View File

@@ -84,7 +84,7 @@ public:
void SetProperty(const std::string& prop, const char* value,
cmListFileBacktrace const& lfbt);
void AppendProperty(const std::string& prop, const char* value,
void AppendProperty(const std::string& prop, const std::string& value,
bool asString, cmListFileBacktrace const& lfbt);
const char* GetProperty(const std::string& prop) const;
const char* GetProperty(const std::string& prop, bool chain) const;

View File

@@ -1297,8 +1297,8 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
}
}
void cmTarget::AppendProperty(const std::string& prop, const char* value,
bool asString)
void cmTarget::AppendProperty(const std::string& prop,
const std::string& value, bool asString)
{
if (!cmTargetPropertyComputer::PassesWhitelist(
this->GetType(), prop, impl->Makefile->GetMessenger(),
@@ -1333,37 +1333,37 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
return;
}
if (prop == "INCLUDE_DIRECTORIES") {
if (value && *value) {
if (!value.empty()) {
impl->IncludeDirectoriesEntries.emplace_back(value);
cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
impl->IncludeDirectoriesBacktraces.push_back(lfbt);
}
} else if (prop == "COMPILE_OPTIONS") {
if (value && *value) {
if (!value.empty()) {
impl->CompileOptionsEntries.emplace_back(value);
cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
impl->CompileOptionsBacktraces.push_back(lfbt);
}
} else if (prop == "COMPILE_FEATURES") {
if (value && *value) {
if (!value.empty()) {
impl->CompileFeaturesEntries.emplace_back(value);
cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
impl->CompileFeaturesBacktraces.push_back(lfbt);
}
} else if (prop == "COMPILE_DEFINITIONS") {
if (value && *value) {
if (!value.empty()) {
impl->CompileDefinitionsEntries.emplace_back(value);
cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
impl->CompileDefinitionsBacktraces.push_back(lfbt);
}
} else if (prop == "LINK_OPTIONS") {
if (value && *value) {
if (!value.empty()) {
impl->LinkOptionsEntries.emplace_back(value);
cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
impl->LinkOptionsBacktraces.push_back(lfbt);
}
} else if (prop == "LINK_DIRECTORIES") {
if (value && *value) {
if (!value.empty()) {
impl->LinkDirectoriesEntries.emplace_back(value);
cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
impl->LinkDirectoriesBacktraces.push_back(lfbt);
@@ -1377,13 +1377,13 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
return;
}
if (value && *value) {
if (!value.empty()) {
impl->PrecompileHeadersEntries.emplace_back(value);
cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
impl->PrecompileHeadersBacktraces.push_back(lfbt);
}
} else if (prop == "LINK_LIBRARIES") {
if (value && *value) {
if (!value.empty()) {
cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
impl->LinkImplementationPropertyEntries.emplace_back(value);
impl->LinkImplementationPropertyBacktraces.push_back(lfbt);

View File

@@ -166,13 +166,8 @@ public:
{
SetProperty(prop, value.c_str());
}
void AppendProperty(const std::string& prop, const char* value,
bool asString = false);
void AppendProperty(const std::string& prop, const std::string& value,
bool asString = false)
{
AppendProperty(prop, value.c_str(), asString);
}
bool asString = false);
//! Might return a nullptr if the property is not set or invalid
const char* GetProperty(const std::string& prop) const;
//! Always returns a valid pointer

View File

@@ -55,7 +55,7 @@ void cmTest::SetProperty(const std::string& prop, const char* value)
this->Properties.SetProperty(prop, value);
}
void cmTest::AppendProperty(const std::string& prop, const char* value,
void cmTest::AppendProperty(const std::string& prop, const std::string& value,
bool asString)
{
this->Properties.AppendProperty(prop, value, asString);

View File

@@ -35,7 +35,7 @@ public:
//! Set/Get a property of this source file
void SetProperty(const std::string& prop, const char* value);
void AppendProperty(const std::string& prop, const char* value,
void AppendProperty(const std::string& prop, const std::string& value,
bool asString = false);
const char* GetProperty(const std::string& prop) const;
bool GetPropertyAsBool(const std::string& prop) const;

View File

@@ -2374,7 +2374,7 @@ void cmake::SetProperty(const std::string& prop, const char* value)
this->State->SetGlobalProperty(prop, value);
}
void cmake::AppendProperty(const std::string& prop, const char* value,
void cmake::AppendProperty(const std::string& prop, const std::string& value,
bool asString)
{
this->State->AppendGlobalProperty(prop, value, asString);

View File

@@ -359,7 +359,7 @@ public:
//! Set/Get a property of this target file
void SetProperty(const std::string& prop, const char* value);
void AppendProperty(const std::string& prop, const char* value,
void AppendProperty(const std::string& prop, const std::string& value,
bool asString = false);
const char* GetProperty(const std::string& prop);
bool GetPropertyAsBool(const std::string& prop);