Setting Global Preprocessor definitions for a module

I want to add a processor definition that can be defined at a project level that would set it globally for the engine too.

This is mainly for engine changes that should only be taken into account for a certain project (ie WITH_GAME). Is there any way to define this in the Game.Target.cs or Game.Build.cs ?

Thanks for your help!

2 Likes

This is possible by adding your definition to your Game.Build.cs file.

using UnrealBuildTool;

public class DemoGame : ModuleRules
{
	public DemoGame(TargetInfo Target)
	{
        // Adding your definition here, will add a global Preprocessor value for cpp
        Definitions.Add("UE_DEMOGAME=1");
        PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
		PrivateDependencyModuleNames.AddRange(new string[] {  });
	}
}
1 Like

Great answer, very useful!

This doesn’t seem to work for include folder in ThridPary folder

i am trying to add a new global Preprocessor . i added it inside Game.Build.cs but during engine start up it always says not defined. any idea

Has this declaration changed form to:

PublicDefinitions.Add(“WITH_XXX=1”);

7 Likes

I get "is not defined as a preprocessor macro, replacing with ‘0’ for ‘#if/#elif’ " if I try and check it in engine code.