头文件与源文件相关配置:
include_directories(
include
${catkin_INCLUDE_DIRS}
)
## 声明C++库
add_library(head
include/test_head_src/haha.h
src/haha.cpp
)
add_dependencies(head ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(head
${catkin_LIBRARIES}
)
可执行文件配置:
add_executable(use_head src/use_head.cpp)
add_dependencies(use_head ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
#此处需要添加之前设置的 head 库
target_link_libraries(use_head
head
${catkin_LIBRARIES}
)