UnrealBuildTool: Finding UE4 root install


I’ve got a plugin module that compiles against an external library. The external library has headers that conflict with UE4’s (it has it’s own DateTime.h for example). My workaround is to include the UE4 header path explicitly in my build.cs ahead of my third party includes.

// Windows Example
ue4_incpath = Path.GetFullPath("/Program Files/Unreal Engine/4.7/Engine/Source/Runtime/Core/Public/Misc");

Is there a better way to do this? Specifically, is there a programatic way in UBT to find the source path for the UE4 install I’m building against?

Ok, I’ll self-answer this one.

The BuildConfiguration global has a RelativeEnginePath member which will give you the relative path to the engine install you’re building against.

ue4_include_path = Path.GetFullPath( Path.Combine( BuildConfiguration.RelativeEnginePath, "Source/Runtime/Core/Public/Misc" ) );
PrivateIncludePaths.Add( ue4_include_path );