Conan (https://conan.io) package for C++ fmt format library
Using the header-only approach. Tested and working in 94 different configurations in Windows, Linux and Mac:
Add it to your requirements in conanfile.txt or conanfile.py:
[requires]
fmt/3.0.0@memsharded/testing
[generators]
cmake
If you are not using cmake in your project, check other conan generators.
Your example.cpp:
#include <iostream>
#include "fmt/format.h"
int main() {
std::string message = fmt::format("The answer is {}", 42);
std::cout<<message<<"\n";
}
project(YourProject)
cmake_minimum_required(VERSION 2.8.12)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
add_executable(example example.cpp)
target_link_libraries(example ${CONAN_LIBS})
Then you can use it as:
$ mkdir build && cd build
$ conan install .. --build=missing (this will use your default conan settings)
$ cmake .. -G "Visual Studio 14 Win64"
$ cmake --build . --config Release
$ bin/example
Note that I am using --build=missing
. I haven't uploaded binary packages yet, just the recipe,
so the package has to be built from sources.