summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalXCodeGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-12-17 17:23:25 (GMT)
committerBrad King <brad.king@kitware.com>2020-12-21 15:19:45 (GMT)
commit6b6230b23b290694aad4c05d7a32fd8241f93ca5 (patch)
tree56d71e5ef9f900787613484c09244a8cbacf49d3 /Source/cmGlobalXCodeGenerator.cxx
parent05a59f37abd982b249f8cad648640c3394acc98a (diff)
downloadCMake-6b6230b23b290694aad4c05d7a32fd8241f93ca5.zip
CMake-6b6230b23b290694aad4c05d7a32fd8241f93ca5.tar.gz
CMake-6b6230b23b290694aad4c05d7a32fd8241f93ca5.tar.bz2
cmGlobalXCodeGenerator: Factor out helper to append attribute
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx63
1 files changed, 35 insertions, 28 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index b6fedaf..1ad611a 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -3213,36 +3213,43 @@ void cmGlobalXCodeGenerator::AppendOrAddBuildSetting(cmXCodeObject* settings,
if (!attr) {
settings->AddAttribute(attribute, value);
} else {
- 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));
+ this->AppendBuildSettingAttribute(settings, attribute, attr, value);
+ }
+ }
+}
+
+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));
}
}