Skip to content

Commit e6084e4

Browse files
committed
Fixed issue with mock_components being linked even when not needed, using modern cmake
1 parent 1aff36e commit e6084e4

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

controller_interface/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ target_include_directories(controller_interface PUBLIC
2525
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
2626
$<INSTALL_INTERFACE:include/controller_interface>
2727
)
28-
ament_target_dependencies(controller_interface PUBLIC ${THIS_PACKAGE_INCLUDE_DEPENDS})
28+
target_link_libraries(controller_interface PUBLIC
29+
hardware_interface::hardware_interface
30+
rclcpp_lifecycle::rclcpp_lifecycle)
2931
# Causes the visibility macros to use dllexport rather than dllimport,
3032
# which is appropriate when building the dll but not consuming it.
3133
target_compile_definitions(controller_interface PRIVATE "CONTROLLER_INTERFACE_BUILDING_DLL")

hardware_interface/CMakeLists.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,15 @@ target_include_directories(hardware_interface PUBLIC
3434
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
3535
$<INSTALL_INTERFACE:include/hardware_interface>
3636
)
37-
ament_target_dependencies(hardware_interface PUBLIC ${THIS_PACKAGE_INCLUDE_DEPENDS})
37+
target_link_libraries(hardware_interface PUBLIC
38+
rclcpp::rclcpp
39+
rclcpp_lifecycle::rclcpp_lifecycle
40+
pluginlib::pluginlib
41+
rcutils::rcutils
42+
rcpputils::rcpputils
43+
${TinyXML2_LIBRARIES}
44+
${control_msgs_TARGETS}
45+
${lifecycle_msgs_TARGETS})
3846
# Causes the visibility macros to use dllexport rather than dllimport,
3947
# which is appropriate when building the dll but not consuming it.
4048
target_compile_definitions(hardware_interface PRIVATE "HARDWARE_INTERFACE_BUILDING_DLL")
@@ -47,7 +55,7 @@ target_include_directories(mock_components PUBLIC
4755
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
4856
$<INSTALL_INTERFACE:include/hardware_interface>
4957
)
50-
ament_target_dependencies(mock_components PUBLIC ${THIS_PACKAGE_INCLUDE_DEPENDS})
58+
target_link_libraries(mock_components PUBLIC hardware_interface)
5159
# Causes the visibility macros to use dllexport rather than dllimport,
5260
# which is appropriate when building the dll but not consuming it.
5361
target_compile_definitions(mock_components PRIVATE "HARDWARE_INTERFACE_BUILDING_DLL")
@@ -64,7 +72,7 @@ target_include_directories(fake_components PUBLIC
6472
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
6573
$<INSTALL_INTERFACE:include/hardware_interface>
6674
)
67-
ament_target_dependencies(fake_components PUBLIC ${THIS_PACKAGE_INCLUDE_DEPENDS})
75+
target_link_libraries(fake_components PUBLIC hardware_interface)
6876
# Causes the visibility macros to use dllexport rather than dllimport,
6977
# which is appropriate when building the dll but not consuming it.
7078
target_compile_definitions(fake_components PRIVATE "HARDWARE_INTERFACE_BUILDING_DLL")

0 commit comments

Comments
 (0)