🔨

Build Systems

CategoryBuild

Overview

A build system is a set of tools designed to automate the process of program compilation.

The purpose of a build system is to map a set of source files to a target executable.

A C/C++ project is composed of multiple source files that can be compiled into several static or dynamic libraries.

The build process invokes compilers to generate object files from source files, and then linkers to generate the final executables.

A makefile is a set of directives used by a build automation tool to generate a target.

💡
Project files or makefiles are required when working on large projects.

Requirements

Projects Files

Create projects manually in the respective toolsets for each platform.


  • Easy to change settings and find related documentation
  • Convenient to work with the same toolset to setup the project and work on the source files

  • Projects need to be setup separately on each toolsets
  • Difficult to maintain source files and shared settings

Build Tools

Instead of creating and maintaining multiple project files, we can use a cross-platform build tool to generate the project files for us.

Make

Make was created at Bell Labs in 1976.

The modern version of Make is GNU Make.

It is one of the most widespread open-source build tool.

The principle of Make is to define:


  • Open-source
  • Small and simple

  • Makefiles are not portable and need to be setup on each platform
  • Specifying source files dependencies is difficult
  • Specifying makefiles dependencies is also difficult
  • Difficult to write makefiles in a large project
  • The tab syntax is akward
  • Cannot work with the platform's native tools

CMake

CMake is open-source and cross-platform created in 2000.

The modern CMake is version 3.0 and was released in June 2014.

The build process is split in two stages:

The principle of CMake is to write CMakeLists.txt files in a directory hierarchy to control the build process. The CMakeLists.txt files contain a list of commands to define the build rules.


  • Open-source
  • Cross-platform
  • Support directory hierarchies
  • Generates the platform's project files
  • Easy to switch between static and dynamic libraries
  • Integrated in Visual Studio 2017 & 2019

  • Generates a lot of intermediate files

Usage

References

Unreal Engine 4

Unreal Engine provides UnrealBuildTool (UBT) as a custom tool for automating the build process.

Unity Engine

The Unity build system is based on a combination of JamPlus and C# scripts.

JamPlus is based on the original Perforce version of Jam.

The transition from JamPlus to C# is internally called "JamSharp". It is JamPlus with support for Mono. The build scripts are written in C# instead of the Jam language.

Sharpmake

Sharpmake is an open-source build tool based on C# that generates native project files.

It was developed internally at Ubisoft for Assassin's Creed 3 in 2011.

It is designed for speed and scale.