fmt 安装和编译:
git clone https://github.com/fmtlib/fmt.git
cd fmt
cmake .
make
等编译完成后将 fmt 库直接添加到工程文件夹里面
将 fmt 库添加到工程文件里面:CMake
add_subdirectory(fmt)
list(APPEND fmt/include)
target_link_libraries(classgo PRIVATE fmt::fmt)
然后编写工程编译输出:
#include <iostream>
#include "fmt/include/fmt/format.h"
#include "fmt/include/fmt/color.h"
using namespace std;
int main()
{
fmt::print(fg(fmt::color::yellow),"hello format {}\n",0x1b);
}
使用CMakeLists.txt 也可以使用
cmake_minimum_required(VERSION 3.1...3.18)
project(fmt-test)
find_package(FMT REQUIRED)
add_executable(fmt_test main.cpp)
target_link_libraries(fmt_test fmt::fmt)