Cleanup docs

This commit is contained in:
Victor Zverovich
2025-10-12 10:18:45 -07:00
parent c4f70ab69e
commit 41326207c7

View File

@@ -716,63 +716,45 @@ enable or disable features and to optimize for binary size. For example, you
can disable OS-specific APIs defined in `fmt/os.h` with `-DFMT_OS=OFF` when can disable OS-specific APIs defined in `fmt/os.h` with `-DFMT_OS=OFF` when
configuring CMake. configuring CMake.
### Available Options ### CMake Options
- **`FMT_HEADER_ONLY`** - **`FMT_OS`**: When set to `OFF`, disables OS-specific APIs (`fmt/os.h`).
Default: `0` - **`FMT_UNICODE`**: When set of `OFF`, disables Unicode support on
Enables header-only mode when set to `1` (CMake target `fmt::fmt-header-only` Windows/MSVC. Unicode support is always enabled on other platforms.
defines it); disable with `0` for library mode.
- **`FMT_OS`** ### Macros
Default: `ON`
Enables OS-specific APIs (`fmt/os.h`); disable with `OFF`.
- **`FMT_UNICODE`** - **`FMT_HEADER_ONLY`**: Enables the header-only mode when set to `1` as an
Default: `ON` alternative to using the `fmt::fmt-header-only` CMake target. Default: `0`.
Enables Unicode support; disable with `OFF`.
- **`FMT_USE_EXCEPTIONS`** - **`FMT_USE_EXCEPTIONS`**: Disables the use of exceptions when set to `0`.
Default: `1` (`0` if compiled with `-fno-exceptions`) Default: `1` (`0` if compiled with `-fno-exceptions`).
Enables exception-based error handling; disable with `0`.
- **`FMT_BUILTIN_TYPES`** - **`FMT_USE_LOCALE`**: When set to `0`, disables locale support.
Default: `1` Default: `1` (`0` when `FMT_OPTIMIZE_SIZE > 1`).
Enables built-in type formatters; disable with `0`.
- **`FMT_OPTIMIZE_SIZE`** - **`FMT_CUSTOM_ASSERT_FAIL`**: When set to `1`, allows users to provide a
Default: `0` custom `fmt::assert_fail` function which is called on assertion failures and,
Controls size-optimized routines: `0` = off, `1` = size optimization, `>1` = if exceptions are disabled, on runtime errors. Default: `0`.
aggressive size optimization disabling format-string checks.
- **`FMT_USE_LOCALE`** - **`FMT_BUILTIN_TYPES`**: When set to `0`, disables built-in handling of
Default: `1` (`0` when `FMT_OPTIMIZE_SIZE > 1`) arithmetic and string types other than `int`. This reduces library size at
Enables locale-dependent formatting; disable with `0`. the cost of per-call overhead. Default: `1`.
- **`FMT_THROW(x)`** - **`FMT_OPTIMIZE_SIZE`**: Controls binary size optimizations:
Default: ``throw x`` (or `abort`) - `0` - off (default)
Defines error handling via macro (not a toggle flag): if exceptions enabled, - `1` - disables locale support and applies some optimizations
`throw x`; otherwise, `fmt::assert_fail(...)`. - `2` - disables some Unicode features, named arguments and applies more
aggresive optimizations
### Binary Size Optimization ### Binary Size Optimization
To minimize your binary footprint, use the following CMake configuration and To minimize the binary footprint of {fmt} as much as possible at the cost of
compile definitions: some features, you can use the following configuration:
```cmake - CMake options:
# Link to the header-only target - `FMT_OS=OFF`
target_link_libraries(${PROJECT_NAME} PRIVATE fmt::fmt-header-only) - Macros:
# Disable OS-specific APIs - `FMT_USE_EXCEPTIONS=0`
set(FMT_OS OFF CACHE BOOL "" FORCE) - `FMT_BUILTIN_TYPES=0`
# Disable Unicode support - `FMT_OPTIMIZE_SIZE=2`
set(FMT_UNICODE OFF CACHE BOOL "" FORCE)
# Add compile definitions to your target
target_compile_definitions(
${PROJECT_NAME}
PRIVATE
FMT_USE_EXCEPTIONS=0
FMT_OS=0
FMT_BUILTIN_TYPES=0
FMT_OPTIMIZE_SIZE=2
FMT_USE_LOCALE=0
)
```