Skip to content
Felix Jones edited this page Oct 1, 2023 · 10 revisions

gba-toolchain Developer Wiki

Installing to .gba ROM binary

install_rom(<target> [DESTINATION <dir>] 
            [CONCAT [ALIGN <byte>] <source>...])

This command generates installation rules for producing a .gba ROM binary.

See cmake.org Installing and Testing, Build and Run for a guide to executing an installation rule.

Part of the ROM installation includes "fixing" the ROM header with the GbaFix script. Fields of the ROM header may be configured with the following target properties:

set_target_properties(<target> PROPERTIES
                      [ROM_TITLE <12-char-title>]
                      [ROM_ID <4-char-id>]
                      [ROM_MAKER <2-char-byte>]
                      [ROM_VERSION <0..255>])

Additional install_rom options are:

DESTINATION

Specify the directory on disk to which the ROM will be installed. Arguments can be relative or absolute paths.

If a relative path is given it is interpreted relative to the value of the CMAKE_INSTALL_PREFIX variable.

If an absolute path (with a leading slash or drive letter) is given it is used verbatim.

CONCAT

Specify additional binary files to be concatenated to the end of the ROM file.

The start of each binary file can be aligned to a given byte with ALIGN <byte>. For example:

install_rom(gbaexecutable CONCAT ALIGN 256 A.bin B.bin C.bin)

Will concatenate files A.bin, B.bin, and C.bin to the end of gbaexecutable's ROM file, each one aligned to a multiple of 256 bytes.

Asset libraries

add_asset_library(<name> [PREFIX <prefix-name>]
                  <source>...)

Creates an asset library target called <name> to bundle source files listed in the command invocation into an OBJECT library.

Internally, an asset library is an OBJECT library with the properties ASSETS (the list of sources).

The only object in the OBJECT library is a compiled assembly source file of all the sources generated with bin2s, or a Bin2S-like script.

OBJECT libraries can be linked to with target_link_libraries(). For example:

target_link_libraries(A PUBLIC assetlibrary)

Will link assetlibrary's compiled object with target A.

The compiled object may also be referenced with an expression in the form $<TARGET_OBJECTS:assetlibrary>. For example:

add_library(... $<TARGET_OBJECTS:assetlibrary> ...)
add_executable(... $<TARGET_OBJECTS:assetlibrary> ...)

Will include assetlibrary's object file in a library and an executable along with those compiled from their own sources.

Additional add_asset_library options are:

PREFIX

Specify a prefix name to be prepended to the symbol of each asset file. For example:

add_asset_library(assetlibrary PREFIX "my_asset_" file.bin)

Will prefix the symbols for file.bin with the string my_asset_:

extern const char my_asset_file_bin[];
extern const char my_asset_file_bin_end[];
extern const unsigned int my_asset_file_size;