From dc8c943372e33a545c531163c5397dcb9ec70e66 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Mon, 29 May 2017 16:58:41 -0600 Subject: [PATCH] Describe cmake use of header-only target --- doc/usage.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/doc/usage.rst b/doc/usage.rst index 3045cb15..dff312df 100644 --- a/doc/usage.rst +++ b/doc/usage.rst @@ -54,6 +54,23 @@ To build a `shared library`__ set the ``BUILD_SHARED_LIBS`` CMake variable to __ http://en.wikipedia.org/wiki/Library_%28computing%29#Shared_libraries +Header-only usage with CMake +============================ + +In order to add ``fmtlib`` into an existing ``CMakeLists.txt`` file, you can add the ``fmt`` library directory into your main project, which will enable the ``fmt`` library:: + + add_subdirectory(fmt) + +If you have a project called ``foo`` that you would like to link against the fmt library in a header-only fashion, you can enable with with:: + + target_link_libraries(foo PRIVATE fmt::fmt-header-only) + +And then to ensure that the ``fmt`` library does not always get built, you can modify the call to ``add_subdirectory`` to read :: + + add_subdirectory(fmt EXCLUDE_FROM_ALL) + +This will ensure that the ``fmt`` library is exluded from calls to ``make``, ``make all``, or ``cmake --build .``. + Building the documentation ==========================