How to enable AVX or SSE optimizations while building UE4 project?

I have a library which uses AVX and SSE optimizations, to enable these it expects " /arch:AVX " flag to be passed to Visual C++ compiler.
I do not see any option to set compiler flags in UE4 project. Is there any way to do this?

Thanks

Engine\Source\Programs\UnrealBuildTool\Windows\VCToolChain.cs

//
			//	PC
			//
			if ((CompileEnvironment.Config.Target.Platform == CPPTargetPlatform.Win32) || 
				(CompileEnvironment.Config.Target.Platform == CPPTargetPlatform.Win64))
			{
				// SSE options are not allowed when using CLR compilation
				if (CompileEnvironment.Config.CLRMode == CPPCLRMode.CLRDisabled && WindowsPlatform.bUseVCCompilerArgs)
				{
					if (CompileEnvironment.Config.bUseAVX)
					{
						// Allow the compiler to generate AVX instructions.
						Arguments.Append(" /arch:AVX");
					}
					// SSE options are not allowed when using the 64 bit toolchain
					// (enables SSE2 automatically)
					else if (CompileEnvironment.Config.Target.Platform != CPPTargetPlatform.Win64)
					{
						// Allow the compiler to generate SSE2 instructions.
						Arguments.Append(" /arch:SSE2");
					}
				}

As you see, you have to provide somehow bUseAVX flag, I believe this may be done in:

public override void SetupGlobalEnvironment(
        TargetInfo Target,
        ref LinkEnvironmentConfiguration OutLinkEnvironmentConfiguration,
        ref CPPEnvironmentConfiguration OutCPPEnvironmentConfiguration
        )
    {
    }

in your project TargetRules. For example take a look at Engine\Source\UE4Game.Target.cs

Hi ,
Sorry for the late reply.

Is there a way to do this without modifying / compiling the engine from source ?

The tried override of SetupGlobalEnvironment in MyGame.Target.cs and MyGameEditor.Target.cs, but it was not called.

Use in your project TargetRules.

 public override void SetupGlobalEnvironment(
         TargetInfo Target,
         ref LinkEnvironmentConfiguration OutLinkEnvironmentConfiguration,
         ref CPPEnvironmentConfiguration OutCPPEnvironmentConfiguration
         )
     {
OutCPPEnvironmentConfiguration.bUseAVX = true;
     }