Skip to main content

Targets

A GPBT target is a named compilation unit: a library, an executable, or a plugin. Each target is declared in its own CMakeLists.txt file using the gpStart* / gpEnd* pair.

Target types

TypeCMake outputMacro
ModuleLibrary (shared or static)gpStartModule()
ExecutableExecutable binarygpStartExecutable()
PluginRuntime-loaded modulegpStartPlugin()

All three types use the same inner API for declaring sources, dependencies, compile flags, and other properties.

Declaring a module

include(gp-build-tool)

gpStartModule("renderer/core")
gpAddDependency(PUBLIC rhi/base)
gpEndModule()

gpStartModule() is equivalent to gpStartTarget("module" ...). gpEndModule() closes the definition.

Declaring an executable

include(gp-build-tool)

gpStartExecutable("editor")
gpAddDependency(PUBLIC core)
gpEndExecutable()

Declaring a plugin

Plugins are loaded at runtime via dlopen() or LoadLibrary(). Declare them with gpStartPlugin():

include(gp-build-tool)

gpStartPlugin("renderer/rhi-d3d12")
gpAddDependency(PUBLIC rhi/base)
gpEndPlugin()
note

Plugin support is reserved for a future release. gpStartPlugin() currently registers the target but does not yet apply any special runtime-loading behaviour beyond what a regular shared library provides.

Target naming

Target names support a / separator to express module hierarchy:

gpStartModule("rhi/base") # hierarchy: rhi layer, base interface
gpStartModule("rhi/d3d12") # hierarchy: rhi layer, D3D12 implementation

The / is converted to an internal clean name. The resulting CMake targets and aliases use underscores:

Declared nameCMake alias
coregp::core
rhi/basegp::rhi_base
rhi/d3d12gp::rhi_d3d12

The output binary name follows a kebab-case convention: gp-rhi-d3d12.

Target location

Each target's CMakeLists.txt must sit in the same directory as the target's source files. GPBT uses that location to find source files via the public/, internal/, and private/ subdirectory convention described in Sources.

The generic form

gpStartModule, gpStartExecutable, and gpStartPlugin are all sugar over gpStartTarget:

gpStartTarget("module" "my/module")
# ...
gpEndTarget()

Use the type-specific macros in practice. gpStartTarget is available for completeness but the specialised forms are clearer.