Home

Awesome

gba-toolchain

Requirements

Basic usage

gba-toolchain provides a CMake toolchain file "cmake/gba.toolchain.cmake" that sets up compilers & tools for GBA development.

For more information on CMake toolchains see: cmake-toolchains cross-compiling

Command line

CMake toolchains can be used with CMake on the command line as such:

cmake -S . -B build --toolchain=/path/to/cmake/gba.toolchain.cmake

Or for CMake versions prior to 3.21:

cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=/path/to/cmake/gba.toolchain.cmake

CMake presets file

For more information on CMake presets files see: cmake-presets configure-preset

Objects of configurePresets has the member toolchainFile:

{
  "version": 3,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 21,
    "patch": 0
  },
  "configurePresets": [
    {
      "name": "gba-toolchain",
      "generator": "Unix Makefiles",
      "toolchainFile": "/path/to/cmake/gba.toolchain.cmake"
    }
  ]
}

Example CMakeLists.txt

cmake_minimum_required(VERSION 3.18)
project(my_project LANGUAGES C)

add_executable(my_executable main.c)

# gba-toolchain sets `CMAKE_SYSTEM_NAME` to `AdvancedGameBoy`
if(CMAKE_SYSTEM_NAME STREQUAL AdvancedGameBoy)
    find_package(librom REQUIRED) # ROM runtime
    find_package(libseven REQUIRED) # C development library
    find_package(agbabi REQUIRED) # Optimized library functions

    target_compile_options(my_executable PRIVATE -mthumb -fconserve-stack -fomit-frame-pointer)
    target_link_libraries(my_executable PRIVATE librom libseven agbabi)
    
    # ROM header info
    set_target_properties(my_executable PROPERTIES
        ROM_TITLE "My Game"
        ROM_ID AABE
        ROM_MAKER CD
        ROM_VERSION 1
    )

    # install to .gba
    install_rom(my_executable)
endif()

CMake modules

CMake modules are made available with the find_package function.

For more information on CMake find_package see: cmake-commands find_package

PackageModuleDescriptionAdditional CMake functions
libromFindlibrom.cmakeROM runtime library for standard .gba ROMs
libmultibootFindlibmultiboot.cmakeMultiboot runtime library for executables transferred via GBA MultiBoot
gba-hppFindgba-hpp.cmakeC++20 GBA development library (more info)
libsevenFindlibseven.cmakeModern C GBA development library from sdk-seven (more info)
libgbaFindlibgba.cmakeC GBA development library from devkitPro (more info)
tonclibFindtonclib.cmakeClassic C GBA development library from Coranac (more info)
gbfsFindgbfs.cmakeArchive format for the GBA (more info)add_gbfs_archive
maxmodFindmaxmod.cmakeGBA music and sound solution (more info)add_maxmod_soundbank
superfamiconvFindsuperfamiconv.cmakeTile graphics converter (more info)add_superfamiconv_graphics
agbabiFindagbabi.cmakeLibrary functions optimized for the GBA (more info)
posprintfFindposprintf.cmakePartial implementation of sprintf optimized for the GBA (more info)
gritFindgrit.cmakeBitmap and Tile graphics converter (more info)add_grit_bitmap<br />add_grit_sprite<br />add_grit_tilemap
butanoFindbutano.cmakeButano engine (more info)add_butano_assets
gbt-playerFindgbt-player.cmakeGame Boy music player library and converter kit (more info)add_gbt_assets<br />add_gbt_maxmod_assets

Important: Some modules may have external dependencies that may require tools to be compiled with a host compiler.