# How to add custom command line flags to UBT

**URL:** <https://forums.unrealengine.com/t/how-to-add-custom-command-line-flags-to-ubt/439294>\
**Category:** Platform & Builds\
**Tags:** Linux, unreal-engine, ubt, UE4, question\
**Created:** [December 11, 2018, 4:35pm UTC](https://forums.unrealengine.com/t/how-to-add-custom-command-line-flags-to-ubt/439294 "2018-12-11T16:35:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_dac2e13d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_dac2e13d](https://forums.unrealengine.com/u/anonymous_user_dac2e13d)\
**Post date:** [December 11, 2018, 4:35pm UTC](https://forums.unrealengine.com/t/how-to-add-custom-command-line-flags-to-ubt/439294/1 "2018-12-11T16:35:10Z")

</div>

How do you add custom flags when using UBT via RunUAT.bat?  
I’m doing this specifically for Linux builds and trying to follow the pattern used by EnableAddressSanitizer.

UEBuildLinux.cs

```
/// <summary>
/// Enables my custom flag
// </summary>
[CommandLine("-MyCustomFlag")]
[XmlConfigFile(Category = "BuildConfiguration", Name = "bMyCustomFlag")]
public bool bMyCustomFlag = false;

```

LinuxToolchain.cs

```
enum LinuxToolChainOptions
{
...
	/// <summary>
	/// Enable some compiler flag
	/// </summary>
	MyCustomFlag = 0x8,
}

```

…

```
protected virtual string GetCLArguments_Global(CppCompileEnvironment CompileEnvironment)

// MyCustomFlag
if (Options.HasFlag(LinuxToolChainOptions.MyCustomFlag))
{
	Result += " -f-some-linux-compiler-flag";
}

```

When I call RunUAT.bat with `-MyCustomFlag=true` or `-MyCustomFlag` that flag is never set, it’s always false.

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![RCL](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RCL](https://forums.unrealengine.com/u/RCL)\
**Post date:** [December 11, 2018, 4:39pm UTC](https://forums.unrealengine.com/t/how-to-add-custom-command-line-flags-to-ubt/439294/2 "2018-12-11T16:39:06Z")

</div>

First, try seeing if your flag is working correctly by invoking UBT directly (e.g. through Engine/Build/BatchFiles/Build.bat or even Engine/Binaries/DotNET/UnrealBuildTool.exe). After that, examine and amend the specific UAT command (I’m guessing it’s BuildCookRun) to make sure the flag (that you’re passing to UAT, not UBT, since RunUAT.bat runs that first) is passed through to UBT from there.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_dac2e13d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_dac2e13d](https://forums.unrealengine.com/u/anonymous_user_dac2e13d)\
**Post date:** [December 12, 2018, 6:30pm UTC](https://forums.unrealengine.com/t/how-to-add-custom-command-line-flags-to-ubt/439294/3 "2018-12-12T18:30:19Z")

</div>

Running the Build.bat file directly helped track down the problem.  
When using RunUAT.bat if you add

```
  -ubtargs=-MyCustomFlag

```

The argument gets passed to UBT and everything works correctly.

Thanks so much for the help!

---

<div class="post-metadata">

**Author:** ![william2013987](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@william2013987](https://forums.unrealengine.com/u/william2013987)\
**Post date:** [May 26, 2022, 11:16pm UTC](https://forums.unrealengine.com/t/how-to-add-custom-command-line-flags-to-ubt/439294/4 "2022-05-26T23:16:48Z")

</div>

Hi

Can explain more where to put this flag ?
