Skip to content
Gabi Melman edited this page Sep 15, 2015 · 1 revision

CMake

The library can also be installed using CMake. Version of CMake must be 3.0+ and can be checked by --version:

> cmake --version
cmake version 3.3.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Generate

Generate project in _builds directory using CMakeLists.txt from current (.) directory, run one of the commands depending on the OS and generator you need:

> cmake -H. -B_builds -DCMAKE_BUILD_TYPE=Release # Default generator is Makefile for *nix platform
> cmake -H. -B_builds -GXcode # Xcode generator on OS X (multi-config, no need for CMAKE_BUILD_TYPE)
> cmake -H. -B_builds "-GVisual Studio 12 2013" # Visual Studio IDE, Windows, multi-config

or toolchains:

> cmake -H. -B_builds -DCMAKE_TOOLCHAIN_FILE=/path/to/iOS.cmake -GXcode
> cmake -H. -B_builds -DCMAKE_TOOLCHAIN_FILE=/path/to/android.cmake -DCMAKE_BUILD_TYPE=Release

To add examples use SPDLOG_BUILD_EXAMPLES=ON option:

> cmake -H. -B_builds -DSPDLOG_BUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Release

Build/test

Open generated project and run build/test targets. Also command line can be used too:

> cmake --build _builds --config Release
> cd _builds && ctest -VV -C Release

Install

Headers can be installed along with the config files so library can be found by find_package(spdlog CONFIG REQUIRED):

[spdlog]> cmake -H. -B_builds -DCMAKE_INSTALL_PREFIX=/path/to/install -DCMAKE_BUILD_TYPE=Release
[spdlog]> cmake --build _builds --target install

Usage can be tested by building examples as a stand-alone project:

[spdlog/examples]> cmake -H. -B_builds -DCMAKE_PREFIX_PATH=/path/to/install -DCMAKE_BUILD_TYPE=Release
[spdlog/examples]> cmake --build _builds
Clone this wiki locally