A profile is a set of build settings: optimization, debug info, LTO, sanitizers and extra flags. Each profile builds into its own directory, target/<profile>/, so switching between them doesn't rebuild everything.
| Profile | Selected with | CMake build type | Default settings |
|---|---|---|---|
| debug | (default) | Debug | opt-level = 0, debug = true |
| release | --release or --profile release | Release | opt-level = 3, debug = false |
A custom profile must say which profile it builds on with inherits. It can inherit from another custom profile. Settings it doesn't set come from the profile it inherits; defines, flags and link-flags add to the inherited ones. A cycle in inherits is an error.
| Key | Values | Applies to | Meaning |
|---|---|---|---|
| inherits | profile name | the profile to build on (custom profiles only) | |
| opt-level | 0, 1, 2, 3, "s", "z" | root package | optimization level (-O<n>, /O1 or /O2 on MSVC) |
| debug | boolean | root package | debug info (-g / /Zi) |
| lto | boolean | every package | link-time optimization, checked with CMake's CheckIPOSupported |
| sanitizers | "address", "undefined", "thread", "memory", "leak" | every package | -fsanitize=...; MSVC only supports address |
| defines | list | root package | added to [build] defines |
| flags | list | root package | added to [build] flags |
| link-flags | list | root package | added to [build] link-flags |
Most settings apply only to the root package. Dependencies are built with the CMake build type of the profile (Debug or Release). Sanitizers and LTO are different: they apply to every package, including plain CMake ones, because a sanitizer build with uninstrumented dependencies gives false results.
Only the root package's [profile.*] sections count, as in Cargo. In a workspace, that's the workspace root's.