Add compiler option (Windows)

Hi everyone,

I tried to look for the way to add compiler option to my project, but I didn’t find anything very clear about it. Some people tell to modify files which doesn’t exist, other tell that you need to build UBT yourself.
I can’t believe there are no easy way to do this but I don’t find the proper documentation about it.

I actually want to add /MD to the compiler command line. The reason around this is that I’m using OpenCV and cv::findCountours, which need this flag to work properly (otherwise you face some memory issues).

Thanks for reading.
Best regards.

EDIT1:

So I found out that we can add some compilier/linker options using:

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

in the PROJECT.Target.cs file. However, the documentation says

The current games do not contain this function, as the UEBuildGame class takes care of their needs by default. However, if a game needed to override these settings, it certainly can do so.

So I’m not sure what it means. Actually, The SetupGlobalEnvironment function is never called during the build process :frowning:

Oh and “it certainly can do so”… yeah but the point of a documentation is to explain how. So please Epic fix this part :smiley:

I finally ended by downloading the UBT source and compile it myself. I also realise that /MD is already enabled.

I really wonder why Epic remove the call to SetupGlobalEnvironment function though. That sounds like “This function call causes an issue, but we don’t know how to fix it, let’s just remove this usefull feature for now” :smiley:

If someone needs more explanation, let me know.

Best regards.