mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-15 20:46:37 +08:00
cmGlobalXCodeGenerator: Factor out helper to append attribute
This commit is contained in:
@@ -3213,39 +3213,46 @@ void cmGlobalXCodeGenerator::AppendOrAddBuildSetting(cmXCodeObject* settings,
|
|||||||
if (!attr) {
|
if (!attr) {
|
||||||
settings->AddAttribute(attribute, value);
|
settings->AddAttribute(attribute, value);
|
||||||
} else {
|
} else {
|
||||||
if (value->GetType() != cmXCodeObject::OBJECT_LIST &&
|
this->AppendBuildSettingAttribute(settings, attribute, attr, value);
|
||||||
value->GetType() != cmXCodeObject::STRING) {
|
|
||||||
cmSystemTools::Error("Unsupported value type for appending: " +
|
|
||||||
std::string(attribute));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (attr->GetType() == cmXCodeObject::OBJECT_LIST) {
|
|
||||||
if (value->GetType() == cmXCodeObject::OBJECT_LIST) {
|
|
||||||
for (auto* obj : value->GetObjectList()) {
|
|
||||||
attr->AddObject(obj);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
attr->AddObject(value);
|
|
||||||
}
|
|
||||||
} else if (attr->GetType() == cmXCodeObject::STRING) {
|
|
||||||
if (value->GetType() == cmXCodeObject::OBJECT_LIST) {
|
|
||||||
// Add old value as a list item to new object list
|
|
||||||
// and replace the attribute with the new list
|
|
||||||
value->PrependObject(attr);
|
|
||||||
settings->AddAttribute(attribute, value);
|
|
||||||
} else {
|
|
||||||
std::string newValue =
|
|
||||||
cmStrCat(attr->GetString(), ' ', value->GetString());
|
|
||||||
attr->SetString(newValue);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cmSystemTools::Error("Unsupported attribute type for appending: " +
|
|
||||||
std::string(attribute));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmGlobalXCodeGenerator::AppendBuildSettingAttribute(
|
||||||
|
cmXCodeObject* settings, const char* attribute, cmXCodeObject* attr,
|
||||||
|
cmXCodeObject* value)
|
||||||
|
{
|
||||||
|
if (value->GetType() != cmXCodeObject::OBJECT_LIST &&
|
||||||
|
value->GetType() != cmXCodeObject::STRING) {
|
||||||
|
cmSystemTools::Error("Unsupported value type for appending: " +
|
||||||
|
std::string(attribute));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (attr->GetType() == cmXCodeObject::OBJECT_LIST) {
|
||||||
|
if (value->GetType() == cmXCodeObject::OBJECT_LIST) {
|
||||||
|
for (auto* obj : value->GetObjectList()) {
|
||||||
|
attr->AddObject(obj);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
attr->AddObject(value);
|
||||||
|
}
|
||||||
|
} else if (attr->GetType() == cmXCodeObject::STRING) {
|
||||||
|
if (value->GetType() == cmXCodeObject::OBJECT_LIST) {
|
||||||
|
// Add old value as a list item to new object list
|
||||||
|
// and replace the attribute with the new list
|
||||||
|
value->PrependObject(attr);
|
||||||
|
settings->AddAttribute(attribute, value);
|
||||||
|
} else {
|
||||||
|
std::string newValue =
|
||||||
|
cmStrCat(attr->GetString(), ' ', value->GetString());
|
||||||
|
attr->SetString(newValue);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cmSystemTools::Error("Unsupported attribute type for appending: " +
|
||||||
|
std::string(attribute));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void cmGlobalXCodeGenerator::AppendBuildSettingAttribute(
|
void cmGlobalXCodeGenerator::AppendBuildSettingAttribute(
|
||||||
cmXCodeObject* target, const char* attribute, cmXCodeObject* value,
|
cmXCodeObject* target, const char* attribute, cmXCodeObject* value,
|
||||||
const std::string& configName)
|
const std::string& configName)
|
||||||
|
@@ -182,6 +182,9 @@ private:
|
|||||||
cmGeneratorTarget* gtgt);
|
cmGeneratorTarget* gtgt);
|
||||||
void AppendOrAddBuildSetting(cmXCodeObject* settings, const char* attr,
|
void AppendOrAddBuildSetting(cmXCodeObject* settings, const char* attr,
|
||||||
cmXCodeObject* value);
|
cmXCodeObject* value);
|
||||||
|
void AppendBuildSettingAttribute(cmXCodeObject* settings,
|
||||||
|
const char* attribute, cmXCodeObject* attr,
|
||||||
|
cmXCodeObject* value);
|
||||||
void AppendBuildSettingAttribute(cmXCodeObject* target, const char* attr,
|
void AppendBuildSettingAttribute(cmXCodeObject* target, const char* attr,
|
||||||
cmXCodeObject* value,
|
cmXCodeObject* value,
|
||||||
const std::string& configName);
|
const std::string& configName);
|
||||||
|
Reference in New Issue
Block a user