Rebuild, deploy, cache

cmake --build build

Default: Ninja + Clang, RelWithDebInfo (-O2 -g), without ThinLTO (SNX_LTO, which the nightlies use). Runtime relinks deploy recompiled/Game/Game[.exe] beside matching Game_code.so/.dll, in the data folder's recompiled/ (Usage); no-op builds skip deployment. Recompiler/ABI edits require module rebuilds.

CPMUtil downloads each package cpmfile.json pins once into a shared .cache/cpm cache, at <package>/<version> (<package>/<version>-<key> for a patched one, the first 10 characters of the SHA-512 of its patches), checked by its SHA-512 (Third-party packages). Offline configuration needs the matching sources already in the cache, or -D<package>_CUSTOM_DIR=/path naming a folder that holds one (a package of one file is checked against its pin there too; a patched package, FFmpeg's and FidelityFX-FSR2's, is refused there, as CPMUtil would take it unpatched). A patched package is kept patched in the cache, one folder for each set of patches: trees of branches that patch it otherwise share the cache and not the folder. A folder of patches no tree uses any more stays until it is deleted. With tests on (BUILD_TESTING) and the runtime, libvpx's VP9 test vectors download there too (tests). The Switch runtime's shared font stand-ins download only when it is built (Shared fonts), and GNU Unifont's .hex (the menu's CJK and Hangul letters of game titles) only when the menu is. Override via CMake/env CPM_SOURCE_CACHE. SDL3 is the system's package when find_package finds 3.4.18 or newer, else the pinned static source build; -DSDL3_FORCE_BUNDLED=ON asks for the source build.

Where a package comes from is CPMUtil's to say, by its options (packages.cmake). LZ4, the Vulkan headers and SPIRV-Tools' programs are the pinned ones unless the system's are asked for: -Dlz4_FORCE_SYSTEM=ON, -DVulkan-Headers_FORCE_SYSTEM=ON (the VulkanHeaders package, with its share/vulkan/registry/vk.xml), -DSPIRV-Tools_FORCE_SYSTEM=ON (spirv-opt, spirv-val and spirv-dis on PATH), or -DCPMUTIL_FORCE_SYSTEM=ON for all of them and SDL3. Each must then be there at the pinned version or newer, or the configure stops; LZ4 then links as the system's library. The configure says where each came from: [CPMUtil] Using system package lz4@1.10.0, or [CPMUtil] Using bundled package lz4@v1.10.0 for the pinned source. Every other package is the pinned one whatever they say: the build compiles it into a target of its own, with its own flags or a change of ours (FFmpeg, OpenSSL and the libcurl built on it, jemalloc, zstd, xxHash's x86 dispatcher, libdeflate, miniz, lunasvg and plutovg), or its package cannot be found this way (ENet installs none, yyjson's carries no version). Asking for the system's one of those (-Dyyjson_FORCE_SYSTEM=ON) stops the configure, and CPMUTIL_FORCE_SYSTEM lists the ones it leaves pinned. -D<package>_FORCE_BUNDLED=ON and -DCPMUTIL_FORCE_BUNDLED=ON (CPMUtil's default on Android and iOS) keep the pinned ones. For a package in a prefix of your own, add -DCMAKE_PREFIX_PATH=/path/to/prefix.

CPM.cmake's options from before CPMUtil are read, and said once per build tree with the option that replaces them: -DCPM_USE_LOCAL_PACKAGES=ON (also from the environment) takes LZ4, the Vulkan headers and SPIRV-Tools' programs from the system where it has them at the pinned version or newer, and the pinned ones otherwise, as it did; -DCPM_DOWNLOAD_SDL3=ON is -DSDL3_FORCE_BUNDLED=ON.

FFmpeg, OpenSSL and jemalloc build with their own configure and make, and SPIRV-Tools with its own CMake, in each build tree. With SNX_DEPS_CACHE (CMake or env) naming a folder, a tree reuses a finished build there whose inputs match (source, configure line, compiler, C headers and the cmake file that builds it, see deps_cache.cmake) and publishes the ones it builds, so other trees and branches skip them. A change to any input is a new folder; old ones are only left behind.

A compiler cache is optional. At configure, ccache is used for the C and C++ compiles when it is found, and sccache is used when ccache is not found. With neither installed the build compiles as it does without one. The cache helps a cold build after a clean, while Ninja already reuses the objects of an incremental build. -DSNX_COMPILER_CACHE=off disables it, -DSNX_COMPILER_CACHE=ccache or sccache chooses one, and an explicit -DCMAKE_C_COMPILER_LAUNCHER or -DCMAKE_CXX_COMPILER_LAUNCHER is used as given (CI does this with ccache). ccache comes first because it is faster for local C and C++ than sccache, which suits a shared or remote cache.


Made from docs/dev/build.md at 69237645142c. GPL-3.0-or-later.