|
| 1 | +cmake_minimum_required(VERSION 3.5) |
| 2 | +project(webots_ros2_control) |
| 3 | + |
| 4 | +# Default to C99 |
| 5 | +if(NOT CMAKE_C_STANDARD) |
| 6 | + set(CMAKE_C_STANDARD 99) |
| 7 | +endif() |
| 8 | + |
| 9 | +# Default to C++14 |
| 10 | +if(NOT CMAKE_CXX_STANDARD) |
| 11 | + set(CMAKE_CXX_STANDARD 14) |
| 12 | +endif() |
| 13 | + |
| 14 | +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 15 | + add_compile_options(-Wall -Wextra -Wpedantic) |
| 16 | +endif() |
| 17 | + |
| 18 | +# Dependencies |
| 19 | +find_package(ament_cmake REQUIRED) |
| 20 | +find_package(hardware_interface REQUIRED) |
| 21 | +find_package(controller_manager REQUIRED) |
| 22 | +find_package(pluginlib REQUIRED) |
| 23 | +find_package(rclcpp REQUIRED) |
| 24 | +find_package(webots_ros2_driver REQUIRED) |
| 25 | + |
| 26 | +list(GET webots_ros2_driver_INCLUDE_DIRS 0 webots_ros2_driver_INCLUDE) |
| 27 | +include_directories( |
| 28 | + ${webots_ros2_driver_INCLUDE}/webots/cpp |
| 29 | +) |
| 30 | + |
| 31 | +# webots_ros2 Plugin |
| 32 | +add_library( |
| 33 | + ${PROJECT_NAME} |
| 34 | + SHARED |
| 35 | + src/Ros2Control.cpp |
| 36 | +) |
| 37 | +target_include_directories( |
| 38 | + ${PROJECT_NAME} |
| 39 | + PRIVATE |
| 40 | + include |
| 41 | +) |
| 42 | +ament_target_dependencies( |
| 43 | + ${PROJECT_NAME} |
| 44 | + hardware_interface |
| 45 | + controller_manager |
| 46 | + pluginlib |
| 47 | + rclcpp |
| 48 | + webots_ros2_driver |
| 49 | +) |
| 50 | + |
| 51 | +# Prevent pluginlib from using boost |
| 52 | +target_compile_definitions(${PROJECT_NAME} PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS") |
| 53 | +pluginlib_export_plugin_description_file(webots_ros2_driver webots_ros2_control.xml) |
| 54 | + |
| 55 | +# ros2_control System |
| 56 | +add_library( |
| 57 | + ${PROJECT_NAME}_system |
| 58 | + SHARED |
| 59 | + src/Ros2ControlSystem.cpp |
| 60 | +) |
| 61 | +target_include_directories( |
| 62 | + ${PROJECT_NAME}_system |
| 63 | + PRIVATE |
| 64 | + include |
| 65 | +) |
| 66 | +ament_target_dependencies( |
| 67 | + ${PROJECT_NAME}_system |
| 68 | + hardware_interface |
| 69 | + pluginlib |
| 70 | + rclcpp |
| 71 | + webots_ros2_driver |
| 72 | +) |
| 73 | + |
| 74 | +# Prevent pluginlib from using boost |
| 75 | +target_compile_definitions(${PROJECT_NAME}_system PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS") |
| 76 | +pluginlib_export_plugin_description_file(${PROJECT_NAME} webots_ros2_control_system.xml) |
| 77 | + |
| 78 | +# Common |
| 79 | +install(TARGETS |
| 80 | + ${PROJECT_NAME} |
| 81 | + ${PROJECT_NAME}_system |
| 82 | + ARCHIVE DESTINATION lib |
| 83 | + LIBRARY DESTINATION lib |
| 84 | + RUNTIME DESTINATION bin |
| 85 | +) |
| 86 | +ament_export_include_directories( |
| 87 | + include |
| 88 | +) |
| 89 | + |
| 90 | +if(BUILD_TESTING) |
| 91 | + find_package(ament_cmake_gtest REQUIRED) |
| 92 | +endif() |
| 93 | + |
| 94 | +ament_export_dependencies( |
| 95 | + hardware_interface |
| 96 | + pluginlib |
| 97 | + rclcpp |
| 98 | +) |
| 99 | +ament_export_libraries( |
| 100 | + ${PROJECT_NAME} |
| 101 | + ${PROJECT_NAME}_system |
| 102 | +) |
| 103 | + |
| 104 | +ament_package() |
0 commit comments