Home | History | Annotate | Download | only in doc
      1 *****
      2 Usage
      3 *****
      4 
      5 To use the fmt library, add :file:`format.h` and :file:`format.cc` from
      6 a `release archive <https://github.com/fmtlib/fmt/releases/latest>`_
      7 or the `Git repository <https://github.com/fmtlib/fmt>`_ to your project.
      8 Alternatively, you can :ref:`build the library with CMake <building>`.
      9 
     10 If you are using Visual C++ with precompiled headers, you might need to add
     11 the line ::
     12 
     13    #include "stdafx.h"
     14 
     15 before other includes in :file:`format.cc`.
     16 
     17 .. _building:
     18 
     19 Building the library
     20 ====================
     21 
     22 The included `CMake build script`__ can be used to build the fmt
     23 library on a wide range of platforms. CMake is freely available for
     24 download from http://www.cmake.org/download/.
     25 
     26 __ https://github.com/fmtlib/fmt/blob/master/CMakeLists.txt
     27 
     28 CMake works by generating native makefiles or project files that can
     29 be used in the compiler environment of your choice. The typical
     30 workflow starts with::
     31 
     32   mkdir build          # Create a directory to hold the build output.
     33   cd build
     34   cmake <path/to/fmt>  # Generate native build scripts.
     35 
     36 where :file:`{<path/to/fmt>}` is a path to the ``fmt`` repository.
     37 
     38 If you are on a \*nix system, you should now see a Makefile in the
     39 current directory. Now you can build the library by running :command:`make`.
     40 
     41 Once the library has been built you can invoke :command:`make test` to run
     42 the tests.
     43 
     44 If you use Windows and have Visual Studio installed, a :file:`FORMAT.sln`
     45 file and several :file:`.vcproj` files will be created. You can then build them
     46 using Visual Studio or msbuild.
     47 
     48 On Mac OS X with Xcode installed, an :file:`.xcodeproj` file will be generated.
     49 
     50 To build a `shared library`__ set the ``BUILD_SHARED_LIBS`` CMake variable to
     51 ``TRUE``::
     52 
     53   cmake -DBUILD_SHARED_LIBS=TRUE ...
     54 
     55 __ http://en.wikipedia.org/wiki/Library_%28computing%29#Shared_libraries
     56 
     57 Building the documentation
     58 ==========================
     59 
     60 To build the documentation you need the following software installed on your
     61 system:
     62 
     63 * `Python <https://www.python.org/>`_ with pip and virtualenv
     64 * `Doxygen <http://www.stack.nl/~dimitri/doxygen/>`_
     65 * `Less <http://lesscss.org/>`_ with ``less-plugin-clean-css``.
     66   Ubuntu doesn't package the ``clean-css`` plugin so you should use ``npm``
     67   instead of ``apt`` to install both ``less`` and the plugin::
     68 
     69     sudo npm install -g less less-plugin-clean-css.
     70 
     71 First generate makefiles or project files using CMake as described in
     72 the previous section. Then compile the ``doc`` target/project, for example::
     73 
     74   make doc
     75 
     76 This will generate the HTML documentation in ``doc/html``.
     77   
     78 Android NDK
     79 ===========
     80 
     81 fmt provides `Android.mk file`__ that can be used to build the library
     82 with `Android NDK <https://developer.android.com/tools/sdk/ndk/index.html>`_.
     83 For an example of using fmt with Android NDK, see the
     84 `android-ndk-example <https://github.com/fmtlib/android-ndk-example>`_
     85 repository.
     86 
     87 __ https://github.com/fmtlib/fmt/blob/master/Android.mk
     88 
     89 Homebrew
     90 ========
     91 
     92 fmt can be installed on OS X using `Homebrew <http://brew.sh/>`_::
     93 
     94   brew install fmt
     95