From 238e0f25b273420efe8a49292c0f4f267f359db2 Mon Sep 17 00:00:00 2001 From: Evan Wilde Date: Tue, 11 Oct 2022 09:56:24 -0700 Subject: 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. --- Source/cmGlobalXCodeGenerator.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 6b867d4..c28b22b 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/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 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()) { -- cgit v0.12