diff --git a/Sharpmake.Generators/VisualStudio/ProjectOptionsGenerator.cs b/Sharpmake.Generators/VisualStudio/ProjectOptionsGenerator.cs index b8038237e..9d7f981ea 100644 --- a/Sharpmake.Generators/VisualStudio/ProjectOptionsGenerator.cs +++ b/Sharpmake.Generators/VisualStudio/ProjectOptionsGenerator.cs @@ -1052,6 +1052,16 @@ private void GenerateCompilerOptions(IGenerationContext context, ProjectOptionsG Options.Option(Options.Vc.Compiler.EnableAsan.Enable, () => { context.Options["EnableASAN"] = "true"; context.CommandLineOptions["EnableASAN"] = "/fsanitize=address"; }) ); + context.SelectOption + ( + Options.Option(Options.Vc.Compiler.JumboBuild.Disable, () => { context.Options["JumboBuild"] = FileGeneratorUtilities.RemoveLineTag; context.Options["MaxFilesPerUnityFile"] = FileGeneratorUtilities.RemoveLineTag; }), + Options.Option(Options.Vc.Compiler.JumboBuild.Enable, () => + { + context.Options["JumboBuild"] = "true"; + context.Options["MaxFilesPerUnityFile"] = context.Configuration.MaxFilesPerUnityFile.ToString(); + }) + ); + if (context.DevelopmentEnvironment.IsVisualStudio() && context.DevelopmentEnvironment >= DevEnv.vs2017) { //Options.Vc.Compiler.DefineCPlusPlus. See: https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ diff --git a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BasePlatform.Vcxproj.Template.cs b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BasePlatform.Vcxproj.Template.cs index 6d25d52b7..f34504741 100644 --- a/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BasePlatform.Vcxproj.Template.cs +++ b/Sharpmake.Platforms/Sharpmake.CommonPlatforms/BasePlatform.Vcxproj.Template.cs @@ -180,6 +180,8 @@ public abstract partial class BasePlatform [options.WindowsTargetPlatformVersion] [options.SpectreMitigation] [options.EnableASAN] + [options.JumboBuild] + [options.MaxFilesPerUnityFile] "; diff --git a/Sharpmake/Options.Vc.cs b/Sharpmake/Options.Vc.cs index f2f776fb8..86adebad3 100644 --- a/Sharpmake/Options.Vc.cs +++ b/Sharpmake/Options.Vc.cs @@ -1348,6 +1348,20 @@ public enum EnableAsan [DevEnvVersion(minimum = DevEnv.vs2019)] Enable } + + /// + /// Enable Jumbo/Unity builds + /// + /// + /// Merges multiple translation units together + /// + public enum JumboBuild + { + [Default] + Disable, + [DevEnvVersion(minimum = DevEnv.vs2019)] + Enable + } } public static class CodeAnalysis diff --git a/Sharpmake/Project.Configuration.cs b/Sharpmake/Project.Configuration.cs index 49481db24..d98047456 100644 --- a/Sharpmake/Project.Configuration.cs +++ b/Sharpmake/Project.Configuration.cs @@ -1605,6 +1605,9 @@ public string FastBuildUnityPath /// public bool DoNotGenerateFastBuild = false; + // Unity builds support + public int MaxFilesPerUnityFile = 0; + // container for executable /// /// Represents a build step that invokes an executable on the file system.