CMake toolchain file for cross-compiling PS2 EE/IOP targets against a ps2/setup-sdk install
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
techwritescode 55ede39b9c
All checks were successful
Release / release (push) Successful in 8s
Add CMake toolchain files for the llvm toolchain (EE and IOP)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-12 13:16:12 -05:00
.forgejo/workflows Add CC0 LICENSE and bundle it with every release 2026-09-08 18:31:27 -05:00
cmake Add CMake toolchain files for the llvm toolchain (EE and IOP) 2026-10-12 13:16:12 -05:00
LICENSE Add CC0 LICENSE and bundle it with every release 2026-09-08 18:31:27 -05:00
README.md Add CMake toolchain files for the llvm toolchain (EE and IOP) 2026-10-12 13:16:12 -05:00

cmake

A CMake toolchain file for cross-compiling PS2 EE (and IOP) targets against a real ps2/setup-sdk install, so an upstream project's own CMake build (SDL2, gsKit, ps2_drivers, ps2gl, ps2stuff, ...) can run as-is instead of being hand-translated into a ps2build ps2.yaml.

Split out of sdk-dist (originally share/ps2dev.cmake) once real CI (ps2gl, ps2stuff) started depending on it directly - sdk-dist's own combined ps2dev-suite bundle release is dormant (ps2build update replaces it), but this file isn't part of that bundle at all, so it needed its own home rather than living inside a repo whose actual purpose is retired.

Usage

ps2build update (and therefore ps2/setup-sdk) installs this component itself, straight into $PS2DEV/cmake/ - a real setup-sdk install already has ps2dev.cmake sitting there with no separate fetch needed. CMAKE_TOOLCHAIN_FILE doesn't even need to be passed explicitly: ps2gl/ps2stuff's own CMakeLists.txt already default to $ENV{PS2DEV}/cmake/ps2dev.cmake when nothing else is specified, so a plain

$env:PS2DEV = "C:\ps2dev-consumer"
cmake -S . -B build -G Ninja

is enough. Only pass -DCMAKE_TOOLCHAIN_FILE= explicitly to point at a different checkout of this repo (local development on the toolchain file itself, say).

The file itself requires the PS2DEV environment variable to point at a real ps2/setup-sdk-provisioned directory (ee/, iop/, dvp/, packages/{core,world}/...) - it doesn't infer its root from its own location, since a real install and this repo's own checkout have no fixed relationship to each other.

ps2dev_iop.cmake is the IOP-side counterpart (older, unmodernized - still expects PS2SDK/PS2DEV env vars and a mipsel-none-elf-* on PATH rather than resolving absolute compiler paths itself). Neither ps2gl nor ps2stuff need it; kept here as-is for now, and not installed by ps2build update (only ps2dev.cmake is).

LLVM toolchain

ps2dev_llvm.cmake (EE) and ps2dev_iop_llvm.cmake (IOP) do the same for the LLVM toolchain: clang and lld from $PS2DEV/llvm-toolchain, and packages from $PS2DEV/packages-llvm (or packages when that folder does not exist).

$env:PS2DEV = "C:\ps2dev-consumer"
cmake -S . -B build -G Ninja -DCMAKE_TOOLCHAIN_FILE=$env:PS2DEV/cmake/ps2dev_llvm.cmake

For an IOP module, include ps2dev_iop_llvm.cmake and call ps2_iop_irx(<target>) on the executable target to produce the .irx; pass EXTRA_FLAGS --allow-zero-text for a module without an export table.