Files
kaizen/doc/get-started.md
Simone 5ff285a9ed Squashed 'external/fmt/' changes from 3b70966df..093b39ca5
093b39ca5 Update docs for meson (#4291)
2c3a5698e Simplify a copying the fill from basic_specs
fc1b0f348 Clarify use of FMT_THROW in a comment
1d066890c Resolve C4702 unreachable code warnings
dad323751 Fix a bug when copying the fill from basic_specs
880e1494d Improve xchar support for std::bitset formatter
e3ddede6c Update version
e9ec4fdc8 Bump version
feb72126b Readd FMT_NO_UNIQUE_ADDRESS
8d517e54c Update changelog
563fc74ae Update changelog
3e04222d5 Restore ABI compatibility with 11.0.2
853df39d0 Mention compile-time formatting
11742a09c Clarify that format_string should be used instead of fstring
da24fac10 Document fstring
5fa4bdd75 Define CMake components to allow docs to be installed separately (#4276)
3c8aad8df Update the release script
0e8aad961 Update version
debe784aa Update changelog
f6d112567 Update changelog
73d0d3f75 Fix github API call
08f60f1ef Update changelog
faf3f8408 Bump version
f3a41441d Replace requests with urllib
3f33cb21d Update changelog
b07a90386 Update changelog
a6fba5177 Update changelog
25e292998 Update changelog
00ab2e98b Update changelog
a3ef285ae Always inline const_check to improve debug codegen in clang
28d1abc9d Update changelog
90704b9ef Update changelog
86dae01c2 Fix compatibility with older versions of VS (#4271)
d8a79eafd Document formatting of bit-fields and fields of packed structs
7c3d0152e Use the _MSVC_STL_UPDATE macro to detect STL (#4267)
7c50da538 Allow getting size of dynamic format arg store (#4270)
873670ba3 Make parameter basic_memory_buffer<char, SIZE>& buf of to_string const
735d4cc05 Update changelog
141380172 Allow disabling <filesystem> by define FMT_CPP_LIB_FILESYSTEM=0 (#4259)
4302d7429 Update changelog
0f51ea79d Update changelog
9600fee02 Include <filesystem> only if FMT_CPP_LIB_FILESYSTEM is set (#4258)
47a66c5ec Bump msys2/setup-msys2 from 2.24.0 to 2.25.0 (#4250)
385c01dc7 Allow bit_cast to work for 80bit long double (#4246)
df249d8ad Remove an old workaround
dfad80d1c Remove an old workaround
536cabd56 Export all range join overloads (#4239)
b1a054706 Remove more MSVC 2015 workarounds and fix string_view checks
bfd95392c Remove MSVC 2015 workaround
9ced61bca Replace std::forward for clang-tidy (#4236)
75e5be6ad Sort specifiers
a169d7fa4 Fix chrono formatting syntax doc (#4235)
a6c45dfea Fix modular build
a35389b3c Corrently handle buffer flush
5a3576acc Implement fmt::join for tuple-like objects (#4230)
542600013 Suppress MSVC warnings "C4127: conditional expression is constant" by used const_check (#4233)
720da57ba Remove reference to unused intrinsic
680db66c3 Explicitly export symbols from detail
56ce41ef6 Remove initializer_list dependency
cf50e4d6a Fix const[expr] in context API
6580d7b80 Cleanup the format API
7e73566ce Minor cleanup
8523dba2d Make constexpr precede explicit consistently
e3d3b24fc Minor cleanup
1521bba70 Use consistent types for argument count
00649552a Bump github/codeql-action from 3.26.6 to 3.27.0 (#4223)
4b8e2838f More cleanup
7d4662f7a Remove FMT_BUILTIN_CTZ
27110bc47 Minor cleanup
68f315376 Fix narrowing conversion warning in struct fstring (#4210)
168df9a06 Implement fmt::format_to into std::vector<char> (#4211)
4daa3d591 Fix error: cannot use 'try' with exceptions disabled in Win LLVM Clang (#4208)
e9eaa27e5 Add std::exception to the docs
2b6a786e3 Use standard context in print
a16ff5787 Add support for code units > 0xFFFF in fill
601be1cbe Add support for code units > 0xFFFF in fill
58c185b63 Changing type of data_ to size_t to avoid compilation warnings (#4200)
a0a9ba2af Fix hashes
cc2ba8f9e Cleanup cifuzz action
a18d42b20 Simplify lint (#4197)
4046f9727 Fix -Wmissing-noreturn warning (#4194)
6bdc12a19 detail_exported -> detail
786a4b096 Cleanup fixed_string
2cb3b7c64 Update README.md
e9cba6905 Update README.md
02537548f Cleanup an example
c68c5fa7c Test FMT_BUILTIN_TYPES
22701d5f6 Address build failures when using Tip-of-Tree clang. (#4187)
e62c41ffb Conform `std::iterator_traits<fmt::appender>` to [iterator.traits]/1 (#4185)
18792893d Silencing Wextra-semi warning (#4188)
c90bc9186 Bump actions/checkout from 4.1.6 to 4.2.0 (#4182)
c95722ad6 Improve naming consistency
db06b0df8 Use countl_zero in bigint
b9ec48d9c Cleanup bigint
3faf6f181 Add min_of/max_of
d64b100a3 Relax constexpr
ff9ee0461 Fix handling FMT_BUILTIN_TYPES
1c5883bef Test nondeterministic conversion to format string
cacc3108c Don't assume repeated evaluation of string literal produce the same pointer
fade652ad Require clang >=15 for _BitInt support (#4176)
96dca569a Module linkage fixes for shared build (#4169)
891c9a73a Cleanup format API
9282222b7 Export more
e5b20ff0d Deprecate detail::locale_ref
ff9222354 Simplify locale handling
80c4d42c6 Cleanup format.h

git-subtree-dir: external/fmt
git-subtree-split: 093b39ca5eea129b111060839602bcfaf295125a
2025-01-07 15:10:49 +00:00

6.7 KiB

Get Started

Compile and run {fmt} examples online with Compiler Explorer.

{fmt} is compatible with any build system. The next section describes its usage with CMake, while the Build Systems section covers the rest.

CMake

{fmt} provides two CMake targets: fmt::fmt for the compiled library and fmt::fmt-header-only for the header-only library. It is recommended to use the compiled library for improved build times.

There are three primary ways to use {fmt} with CMake:

  • FetchContent: Starting from CMake 3.11, you can use FetchContent to automatically download {fmt} as a dependency at configure time:

      include(FetchContent)
    
      FetchContent_Declare(
        fmt
        GIT_REPOSITORY https://github.com/fmtlib/fmt
        GIT_TAG        e69e5f977d458f2650bb346dadf2ad30c5320281) # 10.2.1
      FetchContent_MakeAvailable(fmt)
    
      target_link_libraries(<your-target> fmt::fmt)
    
  • Installed: You can find and use an installed version of {fmt} in your CMakeLists.txt file as follows:

      find_package(fmt)
      target_link_libraries(<your-target> fmt::fmt)
    
  • Embedded: You can add the {fmt} source tree to your project and include it in your CMakeLists.txt file:

      add_subdirectory(fmt)
      target_link_libraries(<your-target> fmt::fmt)
    

Installation

Debian/Ubuntu

To install {fmt} on Debian, Ubuntu, or any other Debian-based Linux distribution, use the following command:

apt install libfmt-dev

Homebrew

Install {fmt} on macOS using Homebrew:

brew install fmt

Conda

Install {fmt} on Linux, macOS, and Windows with Conda, using its conda-forge package:

conda install -c conda-forge fmt

vcpkg

Download and install {fmt} using the vcpkg package manager:

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install fmt

Building from Source

CMake works by generating native makefiles or project files that can be used in the compiler environment of your choice. The typical workflow starts with:

mkdir build  # Create a directory to hold the build output.
cd build
cmake ..     # Generate native build scripts.

run in the fmt repository.

If you are on a Unix-like system, you should now see a Makefile in the current directory. Now you can build the library by running make.

Once the library has been built you can invoke make test to run the tests.

You can control generation of the make test target with the FMT_TEST CMake option. This can be useful if you include fmt as a subdirectory in your project but don't want to add fmt's tests to your test target.

To build a shared library set the BUILD_SHARED_LIBS CMake variable to TRUE:

cmake -DBUILD_SHARED_LIBS=TRUE ..

To build a static library with position-independent code (e.g. for linking it into another shared library such as a Python extension), set the CMAKE_POSITION_INDEPENDENT_CODE CMake variable to TRUE:

cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ..

After building the library you can install it on a Unix-like system by running sudo make install.

Building the Docs

To build the documentation you need the following software installed on your system:

First generate makefiles or project files using CMake as described in the previous section. Then compile the doc target/project, for example:

make doc

This will generate the HTML documentation in doc/html.

Build Systems

build2

You can use build2, a dependency manager and a build system, to use {fmt}.

Currently this package is available in these package repositories:

Usage:

  • build2 package name: fmt
  • Library target name: lib{fmt}

To make your build2 project depend on fmt:

  • Add one of the repositories to your configurations, or in your repositories.manifest, if not already there:

      :
      role: prerequisite
      location: https://pkg.cppget.org/1/stable
    
  • Add this package as a dependency to your manifest file (example for version 10):

      depends: fmt ~10.0.0
    
  • Import the target and use it as a prerequisite to your own target using fmt in the appropriate buildfile:

      import fmt = fmt%lib{fmt}
      lib{mylib} : cxx{**} ... $fmt
    

Then build your project as usual with b or bdep update.

Meson

Meson WrapDB includes an fmt package.

Usage:

  • Install the fmt subproject from the WrapDB by running:

      meson wrap install fmt
    

    from the root of your project.

  • In your project's meson.build file, add an entry for the new subproject:

      fmt = subproject('fmt')
      fmt_dep = fmt.get_variable('fmt_dep')
    
  • Include the new dependency object to link with fmt:

      my_build_target = executable(
        'name', 'src/main.cc', dependencies: [fmt_dep])
    

Options:

If desired, {fmt} can be built as a static library, or as a header-only library.

For a static build, use the following subproject definition:

fmt = subproject('fmt', default_options: 'default_library=static')
fmt_dep = fmt.get_variable('fmt_dep')

For the header-only version, use:

fmt = subproject('fmt', default_options: ['header-only=true'])
fmt_dep = fmt.get_variable('fmt_header_only_dep')

Android NDK

{fmt} provides Android.mk file that can be used to build the library with Android NDK.

Other

To use the {fmt} library with any other build system, add include/fmt/base.h, include/fmt/format.h, include/fmt/format-inl.h, src/format.cc and optionally other headers from a release archive or the git repository to your project, add include to include directories and make sure src/format.cc is compiled and linked with your code.