Unreal compiling cpp files that aren't used on platform

I am working on a mulit-platform project with platform specific implementations.

I use a simple pattern with an interface (abstract class) that my platform components implement. These are created accordingly using PLATFORM_X defines. Unfortunately, UBT still compiles the cpp files for unrelated platforms.

My question would be, does ue4 always compile code files that are components, even if the are not used? If so, do you know of a clean way to seperate platform specific implementations (#ifdefs everywhere is not a viable option)?

Thank you.

Hi Socapex,

I believe that it is possible to create a separate module for each platform and then in your build.cs file include the relevant one as a {Public/Private}DependencyModuleNames behind a build platform check.

Hope that helps. Cheers,

That seems like a good solution. No time to implement it right now, but I don’t see why it wouldn’t work. Thank you.

The OnlineSubsystemFacebook solves this by having separate directories per platform that the build.cs for that module includes for only the associated Target.Platform. I’ve been trying to do this, but it seems everything in the game module is always included. Anyone know how you work around that? (or to put it another way - why does it work for the OnlineSubsystemFacebook module? I couldn’t find anything in there explicitly saying not to include source directories in order for the manual addition to be the only way those files are brought into the build.)