How to add compiler flags without affecting overall build process?

I’m using third party application that generates C++ code that I would like to use in my project. The generated code produces some compiler warnings and, by default, Unreal Build Tool instructs compiler to treat all warnings as errors.

I’d like to add compiler flags that would make compiler ignore those specific warnings. I have not found a way to do that without breaking the default build process. I tried modifying TargetRules of my project as follows:

public class MyProjectTarget : TargetRules
{
	// other things here...

	public override void SetupGlobalEnvironment (
			TargetInfo Target,
			ref LinkEnvironmentConfiguration OutLinkEnvironmentConfiguration,
			ref CPPEnvironmentConfiguration OutCPPEnvironmentConfiguration
			)
	{
		OutCPPEnvironmentConfiguration.AdditionalArguments += " -w";
	}

	public override bool ShouldUseSharedBuildEnvironment(TargetInfo Target)
	{
		return false;
	}
}

The flag was actually added, but the build failed with this error:

Runtime/Engine/Classes/Engine/EngineBaseTypes.h:11:10: fatal error: ‘EngineBaseTypes.generated.h’ file not found

So it seems Unreal Header Tool was not called for engine files after this small addition.

Is there a way to add compiler flag, preserving everything else in the build process?