Build.cs & Target.cs

Brief description of Build.cs & Target.cs

Updated over 2 years ago Edit Page Revisions

Build.cs

Build.cs code is attached to each module and defines how the code for each module is built, there are many variables in this class that users can take advantage of to compile code conditionally per different build situation or set up a special types of modules.

using UnrealBuildTool;  
  
public class Placeholder : ModuleRules  
{  
  public Placeholder(ReadOnlyTargetRules Target) : base(Target)  
   {  
     PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
        
   PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });  
   PrivateDependencyModuleNames.AddRange(new string[] {  });  
   
   PrivateDependencyModuleNames.Add("OnlineSubsystem");
  
// Uncomment if you are using Slate UI  
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });       // Uncomment if you are using online features  
// PrivateDependencyModuleNames.Add("OnlineSubsystem");  
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true  }  
}
using UnrealBuildTool;

UnrealBuildTool is a custom tool that manages the process of building Unreal Engine source code across a variety of build configurations.

public class Placeholder : ModuleRules 

ModuleRules are PCHUsage, PublicDependencies, PrivateDependencies, PrivateDependencyModuleNames.AddRange & PrivateDependencyModuleNames.Add among other options.

PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 

Precompiled Header Usage makes overall compile times faster.

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });  
PrivateDependencyModuleNames.AddRange(new string[] {  });  

Unreal Engine's code depends on those modules, you can add more beyond them as you wish & need.

//PrivateDependencyModuleNames.Add("OnlineSubsystem");

PrivateDependencyModuleNames.Add uncomment when you plan to use OnlineSubsystem for example.

Target.cs

Creates .exe for Game, Editor, Client, Server or Program & you can use target to get a lot of the properties of the build's target settings, such as platform or type of build being compiled.

using UnrealBuildTool;
using System.Collections.Generic;

public class PlaceholderTarget : TargetRules
{
    public PlaceholderTarget(TargetInfo Target) : base(Target)
    {
        Type = TargetType.Game; 
        //Type = TargetType.Editor; 
        //Type = TargetType.Client;
        //Type = TargetType.Server; 
        //Type = TargetType.Program;
        //UnrealTargetConfiguration(Unknown, Debug, DebugGame, Development, Shipping, Test)
        //UnrealTargetPlatform(Win32, Win64, Linux, Mac, PS4..)
        DefaultBuildSettings = BuildSettingsVersion.V2;

        ExtraModuleNames.AddRange( new string[] { "Placeholder" } );
    }
}