|
645 | 645 | <ul class="md-nav__list"> |
646 | 646 |
|
647 | 647 | <li class="md-nav__item"> |
648 | | - <a href="#available-options" class="md-nav__link"> |
| 648 | + <a href="#cmake-options" class="md-nav__link"> |
649 | 649 | <span class="md-ellipsis"> |
650 | | - Available Options |
| 650 | + CMake Options |
| 651 | + </span> |
| 652 | + </a> |
| 653 | + |
| 654 | +</li> |
| 655 | + |
| 656 | + <li class="md-nav__item"> |
| 657 | + <a href="#macros" class="md-nav__link"> |
| 658 | + <span class="md-ellipsis"> |
| 659 | + Macros |
651 | 660 | </span> |
652 | 661 | </a> |
653 | 662 |
|
@@ -1977,72 +1986,55 @@ <h2 id="configuration-options">Configuration Options</h2> |
1977 | 1986 | enable or disable features and to optimize for binary size. For example, you |
1978 | 1987 | can disable OS-specific APIs defined in <code>fmt/os.h</code> with <code>-DFMT_OS=OFF</code> when |
1979 | 1988 | configuring CMake.</p> |
1980 | | -<h3 id="available-options">Available Options</h3> |
| 1989 | +<h3 id="cmake-options">CMake Options</h3> |
| 1990 | +<ul> |
| 1991 | +<li><strong><code>FMT_OS</code></strong>: When set to <code>OFF</code>, disables OS-specific APIs (<code>fmt/os.h</code>).</li> |
| 1992 | +<li><strong><code>FMT_UNICODE</code></strong>: When set of <code>OFF</code>, disables Unicode support on |
| 1993 | + Windows/MSVC. Unicode support is always enabled on other platforms.</li> |
| 1994 | +</ul> |
| 1995 | +<h3 id="macros">Macros</h3> |
1981 | 1996 | <ul> |
1982 | 1997 | <li> |
1983 | | -<p><strong><code>FMT_HEADER_ONLY</code></strong> |
1984 | | - Default: <code>0</code> |
1985 | | - Enables header-only mode when set to <code>1</code> (CMake target <code>fmt::fmt-header-only</code> |
1986 | | - defines it); disable with <code>0</code> for library mode.</p> |
1987 | | -</li> |
1988 | | -<li> |
1989 | | -<p><strong><code>FMT_OS</code></strong> |
1990 | | - Default: <code>ON</code> |
1991 | | - Enables OS-specific APIs (<code>fmt/os.h</code>); disable with <code>OFF</code>.</p> |
1992 | | -</li> |
1993 | | -<li> |
1994 | | -<p><strong><code>FMT_UNICODE</code></strong> |
1995 | | - Default: <code>ON</code> |
1996 | | - Enables Unicode support; disable with <code>OFF</code>.</p> |
| 1998 | +<p><strong><code>FMT_HEADER_ONLY</code></strong>: Enables the header-only mode when set to <code>1</code> as an |
| 1999 | + alternative to using the <code>fmt::fmt-header-only</code> CMake target. Default: <code>0</code>.</p> |
1997 | 2000 | </li> |
1998 | 2001 | <li> |
1999 | | -<p><strong><code>FMT_USE_EXCEPTIONS</code></strong> |
2000 | | - Default: <code>1</code> (<code>0</code> if compiled with <code>-fno-exceptions</code>) |
2001 | | - Enables exception-based error handling; disable with <code>0</code>.</p> |
| 2002 | +<p><strong><code>FMT_USE_EXCEPTIONS</code></strong>: Disables the use of exceptions when set to <code>0</code>. |
| 2003 | + Default: <code>1</code> (<code>0</code> if compiled with <code>-fno-exceptions</code>).</p> |
2002 | 2004 | </li> |
2003 | 2005 | <li> |
2004 | | -<p><strong><code>FMT_BUILTIN_TYPES</code></strong> |
2005 | | - Default: <code>1</code> |
2006 | | - Enables built-in type formatters; disable with <code>0</code>.</p> |
| 2006 | +<p><strong><code>FMT_USE_LOCALE</code></strong>: When set to <code>0</code>, disables locale support. |
| 2007 | + Default: <code>1</code> (<code>0</code> when <code>FMT_OPTIMIZE_SIZE > 1</code>).</p> |
2007 | 2008 | </li> |
2008 | 2009 | <li> |
2009 | | -<p><strong><code>FMT_OPTIMIZE_SIZE</code></strong> |
2010 | | - Default: <code>0</code> |
2011 | | - Controls size-optimized routines: <code>0</code> = off, <code>1</code> = size optimization, <code>>1</code> = |
2012 | | - aggressive size optimization disabling format-string checks.</p> |
| 2010 | +<p><strong><code>FMT_CUSTOM_ASSERT_FAIL</code></strong>: When set to <code>1</code>, allows users to provide a |
| 2011 | + custom <code>fmt::assert_fail</code> function which is called on assertion failures and, |
| 2012 | + if exceptions are disabled, on runtime errors. Default: <code>0</code>.</p> |
2013 | 2013 | </li> |
2014 | 2014 | <li> |
2015 | | -<p><strong><code>FMT_USE_LOCALE</code></strong> |
2016 | | - Default: <code>1</code> (<code>0</code> when <code>FMT_OPTIMIZE_SIZE > 1</code>) |
2017 | | - Enables locale-dependent formatting; disable with <code>0</code>.</p> |
| 2015 | +<p><strong><code>FMT_BUILTIN_TYPES</code></strong>: When set to <code>0</code>, disables built-in handling of |
| 2016 | + arithmetic and string types other than <code>int</code>. This reduces library size at |
| 2017 | + the cost of per-call overhead. Default: <code>1</code>.</p> |
2018 | 2018 | </li> |
2019 | 2019 | <li> |
2020 | | -<p><strong><code>FMT_THROW(x)</code></strong> |
2021 | | - Default: <code>throw x</code> (or <code>abort</code>) |
2022 | | - Defines error handling via macro (not a toggle flag): if exceptions enabled, |
2023 | | - <code>throw x</code>; otherwise, <code>fmt::assert_fail(...)</code>.</p> |
| 2020 | +<p><strong><code>FMT_OPTIMIZE_SIZE</code></strong>: Controls binary size optimizations:</p> |
2024 | 2021 | </li> |
| 2022 | +<li><code>0</code> - off (default)</li> |
| 2023 | +<li><code>1</code> - disables locale support and applies some optimizations</li> |
| 2024 | +<li><code>2</code> - disables some Unicode features, named arguments and applies more |
| 2025 | + aggresive optimizations</li> |
2025 | 2026 | </ul> |
2026 | 2027 | <h3 id="binary-size-optimization">Binary Size Optimization</h3> |
2027 | | -<p>To minimize your binary footprint, use the following CMake configuration and |
2028 | | -compile definitions:</p> |
2029 | | -<pre><code class="language-cmake"># Link to the header-only target |
2030 | | -target_link_libraries(${PROJECT_NAME} PRIVATE fmt::fmt-header-only) |
2031 | | -# Disable OS-specific APIs |
2032 | | -set(FMT_OS OFF CACHE BOOL "" FORCE) |
2033 | | -# Disable Unicode support |
2034 | | -set(FMT_UNICODE OFF CACHE BOOL "" FORCE) |
2035 | | -# Add compile definitions to your target |
2036 | | -target_compile_definitions( |
2037 | | - ${PROJECT_NAME} |
2038 | | - PRIVATE |
2039 | | - FMT_USE_EXCEPTIONS=0 |
2040 | | - FMT_OS=0 |
2041 | | - FMT_BUILTIN_TYPES=0 |
2042 | | - FMT_OPTIMIZE_SIZE=2 |
2043 | | - FMT_USE_LOCALE=0 |
2044 | | -) |
2045 | | -</code></pre> |
| 2028 | +<p>To minimize the binary footprint of {fmt} as much as possible at the cost of |
| 2029 | +some features, you can use the following configuration:</p> |
| 2030 | +<ul> |
| 2031 | +<li>CMake options:</li> |
| 2032 | +<li><code>FMT_OS=OFF</code></li> |
| 2033 | +<li>Macros:</li> |
| 2034 | +<li><code>FMT_USE_EXCEPTIONS=0</code></li> |
| 2035 | +<li><code>FMT_BUILTIN_TYPES=0</code></li> |
| 2036 | +<li><code>FMT_OPTIMIZE_SIZE=2</code></li> |
| 2037 | +</ul> |
2046 | 2038 |
|
2047 | 2039 |
|
2048 | 2040 |
|
|
0 commit comments