以添加yaml库为例:
yaml库的名字叫 “yaml-cpp”
搜索yaml:
$ find / -name "*yaml*"
可以找到yaml-cpp的 *-config.cmake文件如下:
/usr/lib/aarch64-linux-gnu/cmake/yaml-cpp/yaml-cpp-config.cmake
打开yaml-cpp-config.cmake
vim /usr/lib/aarch64-linux-gnu/cmake/yaml-cpp/yaml-cpp-config.cmake
可以看到我们常需要用到的几个名字的定义 YAML_CPP_INCLUDE_DIR 和 YAML_CPP_LIBRARIES
在需要引入yaml-cpp的工程的cmakelists.txt里:
find_package(yaml-cpp REQUIRED)
if (NOT yaml-cpp_FOUND)
message(FATAL_ERROR "Not found yaml-cpp, you should install yaml-cpp")
endif ()
include_directories(${YAML_CPP_INCLUDE_DIR})
target_link_libraries(highway_perception_node ${YAML_CPP_LIBRARIES})
完成上面的内容,就可以在cpp文件里include yaml的头文件进行使用了