Modern OpenGL Programming
A practical, engine‑oriented journey into today’s programmable graphics pipeline.
OpenGL Banner
Chapter 3. Modern CMake Architecture for Multi Module Engines

A modern engine is not just a collection of C++ files — it is a modular system built from independent components. To support this architecture, we need a build system that is:

CMake is the industry standard for this kind of work, but most tutorials teach outdated patterns. This article presents modern CMake, designed specifically for multi module engines.

Why Modern CMake Matters
1. Old CMake vs Modern CMake

Old CMake relied on:

Modern CMake uses:

This shift is essential for engine architecture.

2. Why Engines Need Target Based Design

Engines usually have many modules. Our engine has the following modules:

Each module must be:

Target based CMake makes this possible.

Designing the Build Architecture

The GusOnGames engine uses a top level CMakeLists plus module level CMakeLists.

1. Top Level CMakeLists Structure

The top level file:

It does not contain build logic for modules.

This keeps the top level file clean and readable.

2. Module Level CMakeLists Structure

Each module has its own CMakeLists:

Each module:

This enforces clean boundaries.

3. Target Naming Convention

Each module defines its own namespace

This avoids collisions and keeps naming consistent. GLEW is an external library we compile ourselves, but we do not modify in any way. It is written in C and thus has no namespace support.

PUBLIC / PRIVATE / INTERFACE Explained

This is the heart of modern CMake.

1. PUBLIC

The dependency affects:

Example: math headers.

2. PRIVATE

The dependency affects:

Example: internal helper libraries.

3. INTERFACE

The dependency affects:

Example: header only libraries.

CMakePresets.json — Cross Platform Build Profiles

CMakePresets.json is the modern way to define build configurations.

It allows you to define:

This makes the engine easy to build on:

And easy to integrate with IDEs.

1. Recommended Presets for GusOnGames

Configure presets:

Build presets:

Test presets (future):

This gives developers a predictable workflow.

Third Party Dependencies

The engine uses only one library which is built inside the engine.

This, as well as any other libraries we might add, should be:

This keeps the engine clean and maintainable.

Build Orchestration

The top level CMakeLists orchestrates the entire engine.

1. Engine Modules
add_subdirectory(engine/glew)
add_subdirectory(engine/image)
add_subdirectory(engine/math)
add_subdirectory(engine/platform)
add_subdirectory(engine/render)
add_subdirectory(engine/resources)
add_subdirectory(engine/simulation)
add_subdirectory(engine/utils)
2. Examples
add_subdirectory(examples/basic_triangle)
add_subdirectory(examples/physics_demo)
add_subdirectory(examples/game_demo)

Examples are separate executables that link to engine modules.

3. Linking Modules Together

Example:

target_link_libraries(game_demo
    PRIVATE
        engine_platform
        engine_renderer
        engine_simulation
        engine_resources
        engine_math
)

This makes dependencies explicit and predictable.

Summary

This article defined the build architecture of the GusOnGames engine:

This build system is modern, scalable, and perfectly aligned with the engine’s modular architecture.