If you are using Visual C++ with precompiled headers, you might need to add the line
before other includes in
Building the library¶
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 <path/to/fmt> # Generate native build scripts.
<path/to/fmt> is a path to the
If you are on a *nix 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
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
If you use Windows and have Visual Studio installed, a
file and several
.vcproj files will be created. You can then build them
using Visual Studio or msbuild.
On Mac OS X with Xcode installed, an
.xcodeproj file will be generated.
To build a shared library set the
BUILD_SHARED_LIBS CMake variable to
cmake -DBUILD_SHARED_LIBS=TRUE ...
Header-only usage with CMake¶
You can add the
fmt library directory into your project and include it in
to exclude it from
make all, or
cmake --build ..
Settting up your target to use a header-only version of
fmt is equaly easy:
target_link_libraries(<your-target> PRIVATE fmt-header-only)
Building the documentation¶
To build the documentation you need the following software installed on your system:
Python with pip and virtualenv
less-plugin-clean-css. Ubuntu doesn’t package the
clean-cssplugin so you should use
aptto install both
lessand the plugin:
sudo npm install -g less less-plugin-clean-css.
First generate makefiles or project files using CMake as described in
the previous section. Then compile the
doc target/project, for example:
This will generate the HTML documentation in