How to load different dependency modules for different build targets

I need to load different private dependency modules in my build.cs file for different build targets.

I tried the following:

GlobalDefinitions.Add("MY_VAR=0"); in target1.cs
and GlobalDefinitions.Add("MY_VAR=1"); in target2.cs

I need a way to check that in my build.cs file.

Something like this, which doesn’t work.

if (PublicDefinitions.Contains("MY_VAR=1")) {

Anyone have any ideas? Or a different way of handling this?

Figured it out. You can just access the target variables directly in your build.cs file. Add “using System.Linq;” And then you can use if (Target.GlobalDefinitions.Contains("MY_VAR=1"))