How to let a module compiles only in Editor build?

I made a MyProjEditorExtensionModule, I’d like it to be compiled only in Development Editor+Win64 configuration, but not in Shipping+Win64. I mean, I only want it to produce UE4Editor-MyProjEditorExtension.dll but not UE4-MyProjEditorExtension.dll (not sure if this is the right file name, anyway this is the result dll file of the Shipping configuration).

Why I want this is because this module is for the editor only, the game does not need it. I believe the Editor modules made by Epic (of the path Engine/Source/Editor) won’t be compiled when I do a Shipping+Win64 build for my game, right? If so I’d like the same thing.

So is this possible? Or did I misunderstand the mechanism? Thanks.

Hi Marson,

Modules get compiled when they are referenced by other modules or the target being built. If you want to omit your module from specific builds you will want to modify the build.cs file to conditionally reference your module.

For example in the build.cs file you could do something such as this

if(UEBuildConfiguration.bBuildEditor == true)
{
    //reference the module "MyModule"
    PrivateDependencyModuleNames.Add("MyModule");
}

Cheers,

Jonathan

1 Like

Hi Jonathan:

The solution should be fine, but some other questions came to my mind, I hope you can help me again:

  1. Just want to make sure these codes are to be added in MyProj.Build.cs, right?
  2. If I add these codes, then MyModule would be compiled if I’m building the editor version of MyProj, but I can’t specify which editor version. Is there any method to make MyModule only compiles for certain build configuration, I mean the configuration like Development Editor+Win64. Maybe I only want to build MyModule for Debug build or maybe some custom added configuration?
  3. I’m adding codes like OutExtraModuleNames.Add("MyModule") in the MyProjEditor.Target.cs right now, is this the same thing?
  4. Is there any documentation explaining how things like PrivateDependencyModuleNames work? There are so many of them and the only documentation is the comment of these variables, it would be great if any more detailed explanation (maybe with example use) exist.

Thanks.
Marson

  1. Yes.
  2. Just like UEBuildConfiguration.bBuildEditor, you can also use Target.Platform == UnrealTargetPlatform.Win64 && Target.Configuration == UnrealTargetConfiguration.Development to distinguish the target platform.
  3. Not exactly. Build.cs is a makefile for the corresponding module while Target.cs is a build target for your application which is actually your Game’s executable. So what you setup here in SetupBinaries is actually tell the linker to link against those modules into your executable. Means that your Target could contain multiple modules while your module could also depends on multiple extra modules.
  4. Sorry, there’s no documentations for these details come to my mind. But as you said, you can find comments which already explained quite clearly about what those variables means and the best example could be those module build files already made in the engine.