|
1 | | -cmake_minimum_required(VERSION 3.5) |
2 | | -project(controller_interface) |
| 1 | +cmake_minimum_required(VERSION 3.16) |
| 2 | +project(controller_interface LANGUAGES CXX) |
3 | 3 |
|
4 | | -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 4 | +if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)") |
5 | 5 | add_compile_options(-Wall -Wextra -Werror=conversion -Werror=unused-but-set-variable -Werror=return-type -Werror=shadow) |
6 | 6 | endif() |
7 | 7 |
|
| 8 | +set(THIS_PACKAGE_INCLUDE_DEPENDS |
| 9 | + hardware_interface |
| 10 | + rclcpp_lifecycle |
| 11 | +) |
| 12 | + |
8 | 13 | find_package(ament_cmake REQUIRED) |
9 | | -find_package(hardware_interface REQUIRED) |
10 | | -find_package(rclcpp_lifecycle REQUIRED) |
| 14 | +foreach(Dependency IN ITEMS ${THIS_PACKAGE_INCLUDE_DEPENDS}) |
| 15 | + find_package(${Dependency} REQUIRED) |
| 16 | +endforeach() |
11 | 17 |
|
12 | | -add_library( |
13 | | - ${PROJECT_NAME} |
14 | | - SHARED |
| 18 | +add_library(controller_interface SHARED |
15 | 19 | src/controller_interface_base.cpp |
16 | 20 | src/controller_interface.cpp |
17 | 21 | src/chainable_controller_interface.cpp |
18 | 22 | ) |
19 | | -target_include_directories( |
20 | | - ${PROJECT_NAME} |
21 | | - PRIVATE |
22 | | - include |
23 | | -) |
24 | | -ament_target_dependencies( |
25 | | - ${PROJECT_NAME} |
26 | | - hardware_interface |
27 | | - rclcpp_lifecycle |
| 23 | +target_compile_features(controller_interface PUBLIC cxx_std_17) |
| 24 | +target_include_directories(controller_interface PUBLIC |
| 25 | + $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> |
| 26 | + $<INSTALL_INTERFACE:include/controller_interface> |
28 | 27 | ) |
| 28 | +ament_target_dependencies(controller_interface PUBLIC ${THIS_PACKAGE_INCLUDE_DEPENDS}) |
29 | 29 | # Causes the visibility macros to use dllexport rather than dllimport, |
30 | 30 | # which is appropriate when building the dll but not consuming it. |
31 | | -target_compile_definitions(${PROJECT_NAME} PRIVATE "CONTROLLER_INTERFACE_BUILDING_DLL") |
32 | | - |
33 | | -install(DIRECTORY include/ |
34 | | - DESTINATION include |
35 | | -) |
36 | | -install(TARGETS ${PROJECT_NAME} |
37 | | - ARCHIVE DESTINATION lib |
38 | | - LIBRARY DESTINATION lib |
39 | | - RUNTIME DESTINATION bin |
40 | | -) |
| 31 | +target_compile_definitions(controller_interface PRIVATE "CONTROLLER_INTERFACE_BUILDING_DLL") |
41 | 32 |
|
42 | 33 | if(BUILD_TESTING) |
43 | 34 | find_package(ament_cmake_gmock REQUIRED) |
44 | | - |
45 | | - find_package(hardware_interface REQUIRED) |
46 | | - find_package(sensor_msgs REQUIRED) |
47 | 35 | find_package(geometry_msgs REQUIRED) |
| 36 | + find_package(sensor_msgs REQUIRED) |
48 | 37 |
|
49 | 38 | ament_add_gmock(test_controller_interface test/test_controller_interface.cpp) |
50 | | - target_link_libraries(test_controller_interface ${PROJECT_NAME}) |
51 | | - target_include_directories(test_controller_interface PRIVATE include) |
| 39 | + target_link_libraries(test_controller_interface |
| 40 | + controller_interface |
| 41 | + ) |
52 | 42 |
|
53 | 43 | ament_add_gmock(test_controller_with_options test/test_controller_with_options.cpp) |
54 | | - target_link_libraries(test_controller_with_options ${PROJECT_NAME}) |
55 | | - target_include_directories(test_controller_with_options PRIVATE include) |
| 44 | + target_link_libraries(test_controller_with_options |
| 45 | + controller_interface |
| 46 | + ) |
56 | 47 |
|
57 | 48 | ament_add_gmock(test_chainable_controller_interface test/test_chainable_controller_interface.cpp) |
58 | | - target_link_libraries(test_chainable_controller_interface ${PROJECT_NAME}) |
59 | | - target_include_directories(test_chainable_controller_interface PRIVATE include) |
60 | | - ament_target_dependencies(test_chainable_controller_interface hardware_interface) |
| 49 | + target_link_libraries(test_chainable_controller_interface |
| 50 | + controller_interface |
| 51 | + hardware_interface::hardware_interface |
| 52 | + ) |
61 | 53 |
|
62 | | - ament_add_gmock( |
63 | | - test_semantic_component_interface |
64 | | - test/test_semantic_component_interface.cpp |
| 54 | + ament_add_gmock(test_semantic_component_interface test/test_semantic_component_interface.cpp) |
| 55 | + target_link_libraries(test_semantic_component_interface |
| 56 | + controller_interface |
| 57 | + hardware_interface::hardware_interface |
65 | 58 | ) |
66 | | - target_include_directories(test_semantic_component_interface PRIVATE include) |
67 | | - ament_target_dependencies( |
68 | | - test_semantic_component_interface |
69 | | - hardware_interface |
| 59 | + ament_target_dependencies(test_semantic_component_interface |
| 60 | + geometry_msgs |
70 | 61 | ) |
71 | 62 |
|
72 | | - ament_add_gmock( |
73 | | - test_force_torque_sensor |
74 | | - test/test_force_torque_sensor.cpp |
| 63 | + ament_add_gmock(test_force_torque_sensor test/test_force_torque_sensor.cpp) |
| 64 | + target_link_libraries(test_force_torque_sensor |
| 65 | + controller_interface |
| 66 | + hardware_interface::hardware_interface |
75 | 67 | ) |
76 | | - target_include_directories(test_force_torque_sensor PRIVATE include) |
77 | | - ament_target_dependencies( |
78 | | - test_force_torque_sensor |
79 | | - hardware_interface |
| 68 | + ament_target_dependencies(test_force_torque_sensor |
| 69 | + geometry_msgs |
80 | 70 | ) |
81 | 71 |
|
82 | | - ament_add_gmock( |
83 | | - test_imu_sensor |
84 | | - test/test_imu_sensor.cpp |
| 72 | + ament_add_gmock(test_imu_sensor test/test_imu_sensor.cpp) |
| 73 | + target_link_libraries(test_imu_sensor |
| 74 | + controller_interface |
| 75 | + hardware_interface::hardware_interface |
85 | 76 | ) |
86 | | - target_include_directories(test_imu_sensor PRIVATE include) |
87 | | - ament_target_dependencies( |
88 | | - test_imu_sensor |
89 | | - hardware_interface |
| 77 | + ament_target_dependencies(test_imu_sensor |
90 | 78 | sensor_msgs |
91 | 79 | ) |
92 | 80 |
|
93 | 81 | ament_add_gmock(test_pose_sensor test/test_pose_sensor.cpp) |
94 | | - target_include_directories(test_pose_sensor PRIVATE include) |
| 82 | + target_link_libraries(test_pose_sensor |
| 83 | + controller_interface |
| 84 | + hardware_interface::hardware_interface |
| 85 | + ) |
95 | 86 | ament_target_dependencies(test_pose_sensor |
96 | | - hardware_interface |
97 | 87 | geometry_msgs |
98 | 88 | ) |
99 | 89 | endif() |
100 | 90 |
|
101 | | -ament_export_dependencies( |
102 | | - hardware_interface |
103 | | - rclcpp_lifecycle |
104 | | - sensor_msgs |
| 91 | +install( |
| 92 | + DIRECTORY include/ |
| 93 | + DESTINATION include/controller_interface |
105 | 94 | ) |
106 | | -ament_export_include_directories( |
107 | | - include |
108 | | -) |
109 | | -ament_export_libraries( |
110 | | - ${PROJECT_NAME} |
| 95 | +install(TARGETS controller_interface |
| 96 | + EXPORT export_controller_interface |
| 97 | + ARCHIVE DESTINATION lib |
| 98 | + LIBRARY DESTINATION lib |
| 99 | + RUNTIME DESTINATION bin |
111 | 100 | ) |
| 101 | + |
| 102 | +ament_export_targets(export_controller_interface HAS_LIBRARY_TARGET) |
| 103 | +ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS}) |
112 | 104 | ament_package() |
113 | 105 | ament_generate_version_header(${PROJECT_NAME}) |
0 commit comments