浏览代码

Xcode: Set WMO on non-debug build configurations

This patch sets the swift compilation mode to wholemodule in the xcode
generator for all non-debug build configurations at the project level.

Leaving the target build-configurations default ensures that this
default can be overridden easily by editing either the project
configuration from the build settings editor or the per-target
configuration.

When set on versions of Xcode that do not recognize the
`SWIFT_COMPILATION_MODE` setting, Xcode will include the option as a
user-defined setting, but otherwise ignore it.
Evan Wilde 3 年之前
父节点
当前提交
238e0f25b2
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      Source/cmGlobalXCodeGenerator.cxx

+ 8 - 0
Source/cmGlobalXCodeGenerator.cxx

@@ -4378,12 +4378,20 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
     buildSettings->AddAttribute("CODE_SIGNING_ALLOWED",
                                 this->CreateString("NO"));
   }
+  auto debugConfigs = this->GetCMakeInstance()->GetDebugConfigs();
+  std::set<std::string> debugConfigSet(debugConfigs.begin(),
+                                       debugConfigs.end());
 
   for (auto& config : configs) {
     CreateGlobalXCConfigSettings(root, config.second, config.first);
 
     cmXCodeObject* buildSettingsForCfg = this->CreateFlatClone(buildSettings);
 
+    if (debugConfigSet.count(cmSystemTools::UpperCase(config.first)) == 0) {
+      buildSettingsForCfg->AddAttribute("SWIFT_COMPILATION_MODE",
+                                        this->CreateString("wholemodule"));
+    }
+
     // Put this last so it can override existing settings
     // Convert "CMAKE_XCODE_ATTRIBUTE_*" variables directly.
     for (const auto& var : this->CurrentMakefile->GetDefinitions()) {