2020-09-18_08:51:49
A Build.cs file is a C# class that defines how a module should be built.
In the Build.cs file a subclass of ModuleRules is defined.
In the class' constructor we define a number of properties, for example:
- The module's type.
- Compiler definitions/macros.
- Compiler include paths.
- Linker library search paths.
- Additional library dependencies.
<Visibility>DependencyModuleNamesModules this module wishes to import/use. This is howpublicbuild properties of other modules are inherited into this module.PublicModuleNamesis propagated to modules that depend on this module.PrivateModuleNamesare included only when building this module.<Visibility>IncludePathsDirectories that the compiler should look for header files in.PublicIncludePathsshould only contain directories within the module'sPublicsubdirectory.PrivateIncludePathsshould only contain directories within the module'sPrivatesubdirectory. ForPrivateIncludePathsthe given paths are relative to the module'sPrivatedirectory. Directories in thePublicsubdirectory are found and added automatically by Unreal Build Tool, so no need to list them.
Most of these settings can have either public or private visbility.
Public means that any module that depend on this module also get the setting.
Private means that the dependency is only for the module's private implementation, is only used when compiling the module itself.
Private means that only the current module get the settings.
I don't think that Build.cs/ModuleRules has anything like CMake's INTERFACE.
Example Build.cs file:
TODO: Paste some code into here.The Build.cs file has slightly different semantics for modules that represetnt third-party libraries.
Third-party library modules are not compiled by Unreal Buid Tool, but they can provide compiler settings that are inherited by other modules that depend on the third-party library module.
We can detect monolithic builds and add preprocessor definitions based on that:
if (Target.LinkType != TargetLinkType.Monolithic)
{
PrivateDefinitions.Add("MyFlag=1");
}[[2020-08-27_12:24:45]] Third-party libraries
[[2020-09-10_19:55:50]] Modules
[[2020-09-15_21:10:32]] Module types
[[2020-09-11_12:52:42]] ModuleType