在 CMake 项目中集成 turbo/log
假设 turbo/log 已经通过 CMake 构建 或通过包管理器安装,你可以在 CMake 项目中使用 find_package 来链接 turbo/log,示例如下:
cmake_minimum_required(VERSION 3.16)
project(myproj VERSION 1.0)
find_package(turbo 0.8.0 REQUIRED)
add_executable(myapp main.cpp)
target_link_libraries(myapp turbo::turbo_static)
编译生成的目标 myapp 会根据需要自动添加 klog 到其依赖中。
另外,你也可以使用 CMake 的 add_subdirectory 命令,将 turbo 直接包含到项目的子目录中。
在这种情况下,将前面代码中的 find_package 替换为:
add_subdirectory(path/to/turbo)
target_link_libraries(myapp turbo::turbo_static)