How to use custom compiler options?

I need specify some options for C++ compiler, such as /std:c++latest. But can’t get access to this via .build.cs.
Are there ways to specify this?

1 Like

In VCToolChain.cs (\Engine\Source\Programs\UnrealBuildTool\Windows\VCToolChain.cs) you can append additional compilation argument in AppendCLArguments_Global() or AppendCLArguments_CPP(), if it’s c++ specific arguments.

You can do that for every platform you need, (Linus, Mac, IOS, Android, etc) in their respective ToolChain file (LinuxToolChain.cs, for example).

1 Like

Is it possible to do this for prebuilt version of UE?

I know this is an old topic , but I was also wondering the same thing, UE prebuilt does not have the folder UnrealBuildTool

@lzwdgc @4nof “C:\Program Files\Epic Games\UE_4.21\Engine\Source\Programs\UnrealBuildTool\Platform\Windows\VCToolChain.cs”

2 Likes

For anyone else trying to get this to work with a prebuilt version of UE, after you update the VCToolChain.cs file you then have to rebuild “C:\Program Files\Epic Games\UE_5.0\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.sln”

1 Like

Hey guys, I got here from google again in 2024 and have one more thing to add - you don’t need to rebuild UnrealBuildTool.sln it is already exposed as a setting. Just add this to your WhateverProject.build.cs file in the constructor:
bPreprocessOnly = true;
This will make it output the .i files in the Intermediates folder with all the other generated stuff.
There are lots of other settings along these lines as well if you look at [UE-Install-Dir]\Engine\Source\Programs\UnrealBuildTool\Configuration\TargetRules.cs which is the base class of your build target class. These are documented here as well:

1 Like