Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sharpmake.Options.Vc.Compiler.UseStandardConformingPreprocessor support #387

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Sharpmake.Generators/FastBuild/Bff.Template.cs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ public static class ConfigurationFile
+ ' [cmdLineOptions.IgnoreStandardIncludePath]'
+ ' [cmdLineOptions.GeneratePreprocessedFile]'
+ ' [cmdLineOptions.KeepComments]'
+ ' [cmdLineOptions.UseStandardConformingPreprocessor]'
+ ' [cmdLineOptions.StringPooling]'
+ ' [cmdLineOptions.MinimalRebuild]'
+ ' [cmdLineOptions.ExceptionHandling]'
Expand Down
22 changes: 22 additions & 0 deletions Sharpmake.Generators/VisualStudio/ProjectOptionsGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,28 @@ private void GenerateCompilerOptions(IGenerationContext context, ProjectOptionsG
Options.Option(Options.Vc.Compiler.KeepComment.Enable, () => { context.Options["KeepComments"] = "true"; context.CommandLineOptions["KeepComments"] = "/C"; })
);

//Options.Vc.Compiler.UseStandardConformingPreprocessor. See: https://learn.microsoft.com/en-us/cpp/build/reference/zc-preprocessor?view=msvc-170
// Disable /Zc:preprocessor-
// Enable /Zc:preprocessor
context.SelectOption
jspelletier marked this conversation as resolved.
Show resolved Hide resolved
(
Options.Option(Options.Vc.Compiler.UseStandardConformingPreprocessor.Default, () =>
{
context.Options["UseStandardConformingPreprocessor"] = FileGeneratorUtilities.RemoveLineTag;
context.CommandLineOptions["UseStandardConformingPreprocessor"] = FileGeneratorUtilities.RemoveLineTag;
}),
Options.Option(Options.Vc.Compiler.UseStandardConformingPreprocessor.Disable, () =>
{
context.Options["UseStandardConformingPreprocessor"] = "false";
context.CommandLineOptions["UseStandardConformingPreprocessor"] = "/Zc:preprocessor-";
}),
Options.Option(Options.Vc.Compiler.UseStandardConformingPreprocessor.Enable, () =>
{
context.Options["UseStandardConformingPreprocessor"] = "true";
context.CommandLineOptions["UseStandardConformingPreprocessor"] = "/Zc:preprocessor";
})
);

//Options.Vc.Compiler.StringPooling.
// Disable StringPooling="false"
// Enable StringPooling="true" /GF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public abstract partial class BasePlatform
<PreprocessToFile>[options.GeneratePreprocessedFile]</PreprocessToFile>
<PreprocessSuppressLineNumbers>[options.PreprocessSuppressLineNumbers]</PreprocessSuppressLineNumbers>
<PreprocessKeepComments>[options.KeepComments]</PreprocessKeepComments>
<UseStandardPreprocessor>[options.UseStandardConformingPreprocessor]</UseStandardPreprocessor>
<StringPooling>[options.StringPooling]</StringPooling>
<MinimalRebuild>[options.MinimalRebuild]</MinimalRebuild>
<ExceptionHandling>[options.ExceptionHandling]</ExceptionHandling>
Expand Down
11 changes: 11 additions & 0 deletions Sharpmake/Options.Vc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,17 @@ public enum KeepComment
Enable
}

/// <summary>
/// Enables a token-based preprocessor that conforms to C99 and C++11 and later standards.
/// </summary>
public enum UseStandardConformingPreprocessor
{
[Default]
Default,
Disable,
Enable
}

/// <summary>
/// Enables the compiler to create a single read-only copy of identical strings in the program image and in memory during execution, resulting in smaller programs, an optimization called string pooling. /O1, /O2, and /ZI automatically set /GF option.
/// </summary>
Expand Down