| 
									
										
										
										
											2014-10-16 07:12:43 -07:00
										 |  |  | *****
 | 
					
						
							|  |  |  | Usage
 | 
					
						
							|  |  |  | *****
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-30 06:07:59 -08:00
										 |  |  | To use the {fmt} library, add :file:`fmt/core.h`, :file:`fmt/format.h`,
 | 
					
						
							|  |  |  | :file:`fmt/format-inl.h`, :file:`src/format.cc` and optionally other headers
 | 
					
						
							|  |  |  | from a `release archive <https://github.com/fmtlib/fmt/releases/latest>`_ or
 | 
					
						
							|  |  |  | the `Git repository <https://github.com/fmtlib/fmt>`_ to your project.
 | 
					
						
							| 
									
										
										
										
											2014-12-19 07:37:49 -08:00
										 |  |  | Alternatively, you can :ref:`build the library with CMake <building>`.
 | 
					
						
							| 
									
										
										
										
											2014-10-16 07:12:43 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-19 07:37:49 -08:00
										 |  |  | .. _building:
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-18 08:56:49 -07:00
										 |  |  | Building the Library
 | 
					
						
							| 
									
										
										
										
											2014-12-19 07:37:49 -08:00
										 |  |  | ====================
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-27 08:35:59 -07:00
										 |  |  | The included `CMake build script`__ can be used to build the fmt
 | 
					
						
							| 
									
										
										
										
											2014-12-19 07:37:49 -08:00
										 |  |  | library on a wide range of platforms. CMake is freely available for
 | 
					
						
							| 
									
										
										
										
											2020-12-05 22:41:38 +08:00
										 |  |  | download from https://www.cmake.org/download/.
 | 
					
						
							| 
									
										
										
										
											2014-12-19 07:37:49 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-27 08:35:59 -07:00
										 |  |  | __ https://github.com/fmtlib/fmt/blob/master/CMakeLists.txt
 | 
					
						
							| 
									
										
										
										
											2014-12-19 07:37:49 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 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::
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-27 08:35:59 -07:00
										 |  |  |   mkdir build          # Create a directory to hold the build output.
 | 
					
						
							| 
									
										
										
										
											2014-12-19 07:37:49 -08:00
										 |  |  |   cd build
 | 
					
						
							| 
									
										
										
										
											2019-07-27 15:25:26 +01:00
										 |  |  |   cmake ..  # Generate native build scripts.
 | 
					
						
							| 
									
										
										
										
											2014-12-19 07:37:49 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-27 08:35:59 -07:00
										 |  |  | where :file:`{<path/to/fmt>}` is a path to the ``fmt`` repository.
 | 
					
						
							| 
									
										
										
										
											2014-12-19 07:37:49 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | If you are on a \*nix system, you should now see a Makefile in the
 | 
					
						
							| 
									
										
										
										
											2016-04-27 08:35:59 -07:00
										 |  |  | current directory. Now you can build the library by running :command:`make`.
 | 
					
						
							| 
									
										
										
										
											2014-12-19 07:37:49 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | Once the library has been built you can invoke :command:`make test` to run
 | 
					
						
							|  |  |  | the tests.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-10 06:54:26 -08:00
										 |  |  | 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.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-13 19:58:32 -08:00
										 |  |  | If you use Windows and have Visual Studio installed, a :file:`FMT.sln`
 | 
					
						
							| 
									
										
										
										
											2014-12-19 07:37:49 -08:00
										 |  |  | file and several :file:`.vcproj` files will be created. You can then build them
 | 
					
						
							|  |  |  | using Visual Studio or msbuild.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | On Mac OS X with Xcode installed, an :file:`.xcodeproj` file will be generated.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | To build a `shared library`__ set the ``BUILD_SHARED_LIBS`` CMake variable to
 | 
					
						
							|  |  |  | ``TRUE``::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   cmake -DBUILD_SHARED_LIBS=TRUE ...
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-05 22:41:38 +08:00
										 |  |  | __ https://en.wikipedia.org/wiki/Library_%28computing%29#Shared_libraries
 | 
					
						
							| 
									
										
										
										
											2015-02-16 07:09:25 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-19 14:20:54 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | To build a `static library` with position independent code (required if the main
 | 
					
						
							|  |  |  | consumer of the fmt library is a shared library i.e. a Python extension) set the
 | 
					
						
							|  |  |  | ``CMAKE_POSITION_INDEPENDENT_CODE`` CMake variable to ``TRUE``::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   cmake -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE ...
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-18 09:10:17 -07:00
										 |  |  | Installing the Library
 | 
					
						
							|  |  |  | ======================
 | 
					
						
							| 
									
										
										
										
											2018-12-28 15:05:42 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | After building the library you can install it on a Unix-like system by running
 | 
					
						
							|  |  |  | :command:`sudo make install`.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Usage with CMake
 | 
					
						
							|  |  |  | ================
 | 
					
						
							| 
									
										
										
										
											2018-02-01 16:42:53 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | You can add the ``fmt`` library directory into your project and include it in
 | 
					
						
							|  |  |  | your ``CMakeLists.txt`` file::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    add_subdirectory(fmt)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | or
 | 
					
						
							| 
									
										
										
										
											2018-05-13 08:04:39 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-01 16:42:53 -08:00
										 |  |  | ::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    add_subdirectory(fmt EXCLUDE_FROM_ALL)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | to exclude it from ``make``, ``make all``, or ``cmake --build .``.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-27 12:59:51 -07:00
										 |  |  | You can detect and use an installed version of {fmt} as follows::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    find_package(fmt)
 | 
					
						
							|  |  |  |    target_link_libraries(<your-target> fmt::fmt)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-24 13:40:19 +01:00
										 |  |  | Setting up your target to use a header-only version of ``fmt`` is equally easy::
 | 
					
						
							| 
									
										
										
										
											2018-02-01 16:42:53 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-13 12:00:27 +02:00
										 |  |  |    target_link_libraries(<your-target> PRIVATE fmt::fmt-header-only)
 | 
					
						
							| 
									
										
										
										
											2018-02-01 16:42:53 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-29 00:15:15 +02:00
										 |  |  | Usage with build2
 | 
					
						
							|  |  |  | =================
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | You can use `build2 <https://build2.org>`_, a dependency manager and a
 | 
					
						
							|  |  |  | build-system combined, to use ``fmt``.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Currently this package is available in these package repositories:
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | - **https://cppget.org/fmt/** for released and published versions.
 | 
					
						
							|  |  |  | - `The git repository with the sources of the build2 package of fmt <https://github.com/build2-packaging/fmt.git>`_
 | 
					
						
							|  |  |  |   for unreleased or custom revisions of ``fmt``.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | **Usage:**
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | - ``build2`` package name: ``fmt``
 | 
					
						
							|  |  |  | - Library target name : ``lib{fmt}``
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | For example, 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 ``v7.0.x``)::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     depends: fmt ~7.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`.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | For ``build2`` newcomers or to get more details and use cases, you can read the
 | 
					
						
							|  |  |  | ``build2``
 | 
					
						
							|  |  |  | `toolchain introduction <https://build2.org/build2-toolchain/doc/build2-toolchain-intro.xhtml>`_.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-18 08:56:49 -07:00
										 |  |  | Building the Documentation
 | 
					
						
							| 
									
										
										
										
											2015-10-17 08:17:32 -07:00
										 |  |  | ==========================
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | To build the documentation you need the following software installed on your
 | 
					
						
							|  |  |  | system:
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-17 08:21:23 -07:00
										 |  |  | * `Python <https://www.python.org/>`_ with pip and virtualenv
 | 
					
						
							|  |  |  | * `Doxygen <http://www.stack.nl/~dimitri/doxygen/>`_
 | 
					
						
							| 
									
										
										
										
											2016-06-22 07:01:43 -07:00
										 |  |  | * `Less <http://lesscss.org/>`_ with ``less-plugin-clean-css``.
 | 
					
						
							|  |  |  |   Ubuntu doesn't package the ``clean-css`` plugin so you should use ``npm``
 | 
					
						
							|  |  |  |   instead of ``apt`` to install both ``less`` and the plugin::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     sudo npm install -g less less-plugin-clean-css.
 | 
					
						
							| 
									
										
										
										
											2015-10-17 08:17:32 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | First generate makefiles or project files using CMake as described in
 | 
					
						
							| 
									
										
										
										
											2015-10-17 08:34:58 -07:00
										 |  |  | the previous section. Then compile the ``doc`` target/project, for example::
 | 
					
						
							| 
									
										
										
										
											2015-10-17 08:17:32 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   make doc
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-01 12:29:21 +02:00
										 |  |  | This will generate the HTML documentation in ``doc/html``.
 | 
					
						
							| 
									
										
										
										
											2019-11-16 07:30:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | Conda
 | 
					
						
							|  |  |  | =====
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-16 07:14:57 -08:00
										 |  |  | fmt can be installed on Linux, macOS and Windows with
 | 
					
						
							|  |  |  | `Conda <https://docs.conda.io/en/latest/>`__, using its
 | 
					
						
							|  |  |  | `conda-forge <https://conda-forge.org>`__
 | 
					
						
							|  |  |  | `package <https://github.com/conda-forge/fmt-feedstock>`__, as follows::
 | 
					
						
							| 
									
										
										
										
											2019-11-16 07:30:31 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   conda install -c conda-forge fmt
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-18 06:59:21 -08:00
										 |  |  | Vcpkg
 | 
					
						
							|  |  |  | =====
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | You can download and install fmt using the `vcpkg
 | 
					
						
							|  |  |  | <https://github.com/Microsoft/vcpkg>`__ dependency manager::
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   git clone https://github.com/Microsoft/vcpkg.git
 | 
					
						
							|  |  |  |   cd vcpkg
 | 
					
						
							|  |  |  |   ./bootstrap-vcpkg.sh
 | 
					
						
							|  |  |  |   ./vcpkg integrate install
 | 
					
						
							|  |  |  |   ./vcpkg install fmt
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The fmt port in vcpkg is kept up to date by Microsoft team members and community
 | 
					
						
							|  |  |  | contributors. If the version is out of date, please `create an issue or pull
 | 
					
						
							|  |  |  | request <https://github.com/Microsoft/vcpkg>`__ on the vcpkg repository.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-05 14:36:33 +02:00
										 |  |  | LHelper
 | 
					
						
							|  |  |  | =======
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-05 15:42:02 +02:00
										 |  |  | You can download and install fmt using
 | 
					
						
							|  |  |  | `lhelper <https://github.com/franko/lhelper>`__ dependency manager::
 | 
					
						
							| 
									
										
										
										
											2020-10-05 14:36:33 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   lhelper activate <some-environment>
 | 
					
						
							|  |  |  |   lhelper install fmt
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-05 15:42:02 +02:00
										 |  |  | All the recipes for lhelper are kept in the
 | 
					
						
							|  |  |  | `lhelper's recipe <https://github.com/franko/lhelper-recipes>`__ repository.
 | 
					
						
							| 
									
										
										
										
											2020-10-05 14:36:33 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-16 07:09:25 -08:00
										 |  |  | Android NDK
 | 
					
						
							|  |  |  | ===========
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-27 08:35:59 -07:00
										 |  |  | fmt provides `Android.mk file`__ that can be used to build the library
 | 
					
						
							| 
									
										
										
										
											2015-02-16 07:25:45 -08:00
										 |  |  | with `Android NDK <https://developer.android.com/tools/sdk/ndk/index.html>`_.
 | 
					
						
							| 
									
										
										
										
											2016-04-27 08:35:59 -07:00
										 |  |  | For an example of using fmt with Android NDK, see the
 | 
					
						
							|  |  |  | `android-ndk-example <https://github.com/fmtlib/android-ndk-example>`_
 | 
					
						
							| 
									
										
										
										
											2015-02-16 07:09:25 -08:00
										 |  |  | repository.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-09 08:04:58 -08:00
										 |  |  | __ https://github.com/fmtlib/fmt/blob/master/support/Android.mk
 | 
					
						
							| 
									
										
										
										
											2015-05-08 08:19:15 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | Homebrew
 | 
					
						
							|  |  |  | ========
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-05 22:41:38 +08:00
										 |  |  | fmt can be installed on OS X using `Homebrew <https://brew.sh/>`_::
 | 
					
						
							| 
									
										
										
										
											2015-05-08 08:19:15 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-20 07:34:21 +09:00
										 |  |  |   brew install fmt
 |