|
1 | 1 | cmake_minimum_required(VERSION 3.5) |
2 | 2 | project(rosbag2) |
3 | 3 |
|
| 4 | +# Default to C99 |
| 5 | +if(NOT CMAKE_C_STANDARD) |
| 6 | + set(CMAKE_C_STANDARD 99) |
| 7 | +endif() |
| 8 | + |
| 9 | +# Default to C++17 |
| 10 | +if(NOT CMAKE_CXX_STANDARD) |
| 11 | + set(CMAKE_CXX_STANDARD 17) |
| 12 | + set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 13 | +endif() |
| 14 | + |
| 15 | +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 16 | + add_compile_options(-Wall -Wextra -Wpedantic) |
| 17 | +endif() |
| 18 | +if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND MSVC) |
| 19 | + # /bigobj is needed to avoid error C1128: |
| 20 | + # https://msdn.microsoft.com/en-us/library/8578y171.aspx |
| 21 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") |
| 22 | +endif() |
| 23 | + |
| 24 | +# Windows supplies macros for min and max by default. We should only use min and max from stl |
| 25 | +if(WIN32) |
| 26 | + add_definitions(-DNOMINMAX) |
| 27 | +endif() |
| 28 | + |
4 | 29 | find_package(ament_cmake REQUIRED) |
| 30 | +find_package(rclcpp_components REQUIRED) |
| 31 | +find_package(rosbag2_transport REQUIRED) |
| 32 | + |
| 33 | +add_library(${PROJECT_NAME} SHARED |
| 34 | + src/rosbag2/component_player.cpp |
| 35 | +) |
| 36 | + |
| 37 | +target_link_libraries(${PROJECT_NAME} |
| 38 | + rclcpp::rclcpp |
| 39 | + ${rclcpp_components_TARGETS} |
| 40 | + rosbag2_transport::rosbag2_transport |
| 41 | +) |
| 42 | + |
| 43 | +rclcpp_components_register_node(${PROJECT_NAME} |
| 44 | + PLUGIN "rosbag2::Player" |
| 45 | + EXECUTABLE player |
| 46 | +) |
| 47 | + |
| 48 | +install( |
| 49 | + TARGETS ${PROJECT_NAME} |
| 50 | + EXPORT export_${PROJECT_NAME} |
| 51 | + ARCHIVE DESTINATION lib |
| 52 | + LIBRARY DESTINATION lib |
| 53 | + RUNTIME DESTINATION bin |
| 54 | +) |
| 55 | + |
| 56 | +ament_export_libraries(${PROJECT_NAME}) |
| 57 | + |
| 58 | +ament_export_dependencies( |
| 59 | + rclcpp_components |
| 60 | + rosbag2_transport |
| 61 | +) |
| 62 | + |
5 | 63 | ament_package() |
0 commit comments