Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Describe cmake use of header-only target #515

Merged
merged 1 commit into from
May 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions doc/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
==========================

Expand Down