|
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) |
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 | 35 | find_package(sensor_msgs REQUIRED) |
47 | 36 |
|
48 | 37 | ament_add_gmock(test_controller_interface test/test_controller_interface.cpp) |
49 | | - target_link_libraries(test_controller_interface ${PROJECT_NAME}) |
50 | | - target_include_directories(test_controller_interface PRIVATE include) |
| 38 | + target_link_libraries(test_controller_interface |
| 39 | + controller_interface |
| 40 | + ) |
51 | 41 |
|
52 | 42 | ament_add_gmock(test_controller_with_options test/test_controller_with_options.cpp) |
53 | | - target_link_libraries(test_controller_with_options ${PROJECT_NAME}) |
54 | | - target_include_directories(test_controller_with_options PRIVATE include) |
| 43 | + target_link_libraries(test_controller_with_options |
| 44 | + controller_interface |
| 45 | + ) |
55 | 46 |
|
56 | 47 | ament_add_gmock(test_chainable_controller_interface test/test_chainable_controller_interface.cpp) |
57 | | - target_link_libraries(test_chainable_controller_interface ${PROJECT_NAME}) |
58 | | - target_include_directories(test_chainable_controller_interface PRIVATE include) |
59 | | - ament_target_dependencies(test_chainable_controller_interface hardware_interface) |
60 | | - |
61 | | - ament_add_gmock( |
62 | | - test_semantic_component_interface |
63 | | - test/test_semantic_component_interface.cpp |
64 | | - ) |
65 | | - target_include_directories(test_semantic_component_interface PRIVATE include) |
66 | | - ament_target_dependencies( |
67 | | - test_semantic_component_interface |
68 | | - hardware_interface |
| 48 | + target_link_libraries(test_chainable_controller_interface |
| 49 | + controller_interface |
| 50 | + hardware_interface::hardware_interface |
69 | 51 | ) |
70 | 52 |
|
71 | | - ament_add_gmock( |
72 | | - test_force_torque_sensor |
73 | | - test/test_force_torque_sensor.cpp |
| 53 | + ament_add_gmock(test_semantic_component_interface test/test_semantic_component_interface.cpp) |
| 54 | + target_link_libraries(test_semantic_component_interface |
| 55 | + controller_interface |
| 56 | + hardware_interface::hardware_interface |
74 | 57 | ) |
75 | | - target_include_directories(test_force_torque_sensor PRIVATE include) |
76 | | - ament_target_dependencies( |
77 | | - test_force_torque_sensor |
78 | | - hardware_interface |
| 58 | + |
| 59 | + ament_add_gmock(test_force_torque_sensor test/test_force_torque_sensor.cpp) |
| 60 | + target_link_libraries(test_force_torque_sensor |
| 61 | + controller_interface |
| 62 | + hardware_interface::hardware_interface |
79 | 63 | ) |
80 | 64 |
|
81 | | - ament_add_gmock( |
82 | | - test_imu_sensor |
83 | | - test/test_imu_sensor.cpp |
| 65 | + ament_add_gmock(test_imu_sensor test/test_imu_sensor.cpp) |
| 66 | + target_link_libraries(test_imu_sensor |
| 67 | + controller_interface |
| 68 | + hardware_interface::hardware_interface |
84 | 69 | ) |
85 | | - target_include_directories(test_imu_sensor PRIVATE include) |
86 | | - ament_target_dependencies( |
87 | | - test_imu_sensor |
88 | | - hardware_interface |
| 70 | + ament_target_dependencies(test_imu_sensor |
89 | 71 | sensor_msgs |
90 | 72 | ) |
91 | 73 | endif() |
92 | 74 |
|
93 | | -ament_export_dependencies( |
94 | | - hardware_interface |
95 | | - rclcpp_lifecycle |
96 | | - sensor_msgs |
97 | | -) |
98 | | -ament_export_include_directories( |
99 | | - include |
| 75 | +install( |
| 76 | + DIRECTORY include/ |
| 77 | + DESTINATION include/controller_interface |
100 | 78 | ) |
101 | | -ament_export_libraries( |
102 | | - ${PROJECT_NAME} |
| 79 | +install(TARGETS controller_interface |
| 80 | + EXPORT export_controller_interface |
| 81 | + ARCHIVE DESTINATION lib |
| 82 | + LIBRARY DESTINATION lib |
| 83 | + RUNTIME DESTINATION bin |
103 | 84 | ) |
| 85 | + |
| 86 | +ament_export_targets(export_controller_interface HAS_LIBRARY_TARGET) |
| 87 | +ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS}) |
104 | 88 | ament_package() |
0 commit comments