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.
This commit is contained in:
Evan Wilde
2022-10-11 09:56:24 -07:00
committed by Brad King
parent 6063428de7
commit 238e0f25b2

View File

@@ -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()) {