linux c++工程中使用ros编写cmakelist文件
cmake_minimum_required(VERSION 3.8)
project(project1 CXX)
list(APPEND CMAKE_MODULE_PATH /opt/ros/melodic)
find_package(roscpp REQUIRED)
find_package(rosbag REQUIRED)
add_library(lib1 SHARED
file1.h
file1.cc
file2.h
file2.cc
)
target_include_directories(lib1
PUBLIC
${roscpp_INCLUDE_DIRS}
)
target_link_libraries(lib1
PUBLIC
${roscpp_LIBRARIES}
${rosbag_LIBRARIES}
)
target_compile_features(lib1
PUBLIC
cxx_std_17
)
add_executable(test1
main.cc
)
target_include_directories(test1
PRIVATE
${roscpp_INCLUDE_DIRS}
)
target_link_libraries(test1
PRIVATE
lib1
${roscpp_LIBRARIES}
)