• Stars
    star
    102
  • Rank 335,584 (Top 7 %)
  • Language CMake
  • License
    Other
  • Created almost 5 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

CMake based toolchain for GBA homebrew development

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

Package Module Description Additional CMake functions
librom Findlibrom.cmake ROM runtime library for standard .gba ROMs
libmultiboot Findlibmultiboot.cmake Multiboot runtime library for executables transferred via GBA MultiBoot
gba-hpp Findgba-hpp.cmake C++20 GBA development library (more info)
libseven Findlibseven.cmake Modern C GBA development library from sdk-seven (more info)
libgba Findlibgba.cmake C GBA development library from devkitPro (more info)
tonclib Findtonclib.cmake Classic C GBA development library from Coranac (more info)
gbfs Findgbfs.cmake Archive format for the GBA (more info) add_gbfs_archive
maxmod Findmaxmod.cmake GBA music and sound solution (more info) add_maxmod_soundbank
superfamiconv Findsuperfamiconv.cmake Tile graphics converter (more info) add_superfamiconv_graphics
agbabi Findagbabi.cmake Library functions optimized for the GBA (more info)
posprintf Findposprintf.cmake Partial implementation of sprintf optimized for the GBA (more info)
grit Findgrit.cmake Bitmap and Tile graphics converter (more info) add_grit_bitmap
add_grit_sprite
add_grit_tilemap
butano Findbutano.cmake Butano engine (more info) add_butano_assets
gbt-player Findgbt-player.cmake Game Boy music player library and converter kit (more info) add_gbt_assets
add_gbt_maxmod_assets

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