Skip to content

Commit 67e69c4

Browse files
committed
fix compile with qt6
Fixed a rviz_default_plugin compilation error when using qt6. The error is silent if you have qt5 and qt6 installed fix qt6 compile
1 parent 4fc5c82 commit 67e69c4

File tree

15 files changed

+319
-64
lines changed

15 files changed

+319
-64
lines changed

moveit_ros/visualization/CMakeLists.txt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,12 @@ find_package(rviz_ogre_vendor REQUIRED)
3737
# Finds Boost Components
3838
include(ConfigExtras.cmake)
3939

40+
4041
# Qt Stuff
41-
find_package(Qt5 ${rviz_QT_VERSION} REQUIRED Core Widgets)
42-
set(QT_LIBRARIES Qt5::Widgets)
43-
# Delegate to QT5 macro
44-
macro(QT_WRAP_UI)
45-
qt5_wrap_ui(${ARGN})
46-
endmacro()
42+
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Test Widgets)
43+
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Test Widgets)
44+
45+
4746

4847
set(CMAKE_INCLUDE_CURRENT_DIR ON)
4948
set(CMAKE_AUTOMOC ON)
@@ -116,7 +115,7 @@ install(
116115
DESTINATION include/moveit_ros_visualization)
117116

118117
ament_export_targets(moveit_ros_visualizationTargets HAS_LIBRARY_TARGET)
119-
ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS})
118+
ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS} Qt${QT_VERSION_MAJOR} )
120119

121120
ament_package(CONFIG_EXTRAS ConfigExtras.cmake)
122121

moveit_ros/visualization/motion_planning_rviz_plugin/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
2+
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
3+
14
set(HEADERS
25
include/moveit/motion_planning_rviz_plugin/motion_planning_display.hpp
36
include/moveit/motion_planning_rviz_plugin/motion_planning_frame.hpp
47
include/moveit/motion_planning_rviz_plugin/motion_planning_frame_joints_widget.hpp
58
include/moveit/motion_planning_rviz_plugin/motion_planning_param_widget.hpp
69
include/moveit/motion_planning_rviz_plugin/interactive_marker_display.hpp)
7-
qt5_wrap_ui(UIC_FILES src/ui/motion_planning_rviz_plugin_frame.ui
10+
qt_wrap_ui(UIC_FILES src/ui/motion_planning_rviz_plugin_frame.ui
811
src/ui/motion_planning_rviz_plugin_frame_joints.ui)
912

1013
include_directories(${CMAKE_CURRENT_BINARY_DIR})
@@ -38,7 +41,7 @@ ament_target_dependencies(
3841
moveit_ros_warehouse
3942
rviz2
4043
rviz_ogre_vendor
41-
Qt5
44+
Qt${QT_VERSION_MAJOR}
4245
pluginlib)
4346
target_include_directories(moveit_motion_planning_rviz_plugin_core
4447
PRIVATE "${OGRE_PREFIX_DIR}/include")

moveit_ros/visualization/planning_scene_rviz_plugin/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
2+
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
13
add_library(
24
moveit_planning_scene_rviz_plugin_core SHARED
35
src/planning_scene_display.cpp src/background_processing.cpp
@@ -27,7 +29,7 @@ add_library(moveit_planning_scene_rviz_plugin SHARED src/plugin_init.cpp)
2729
set_target_properties(moveit_planning_scene_rviz_plugin
2830
PROPERTIES VERSION "${${PROJECT_NAME}_VERSION}")
2931
target_link_libraries(moveit_planning_scene_rviz_plugin
30-
moveit_planning_scene_rviz_plugin_core Qt5::Widgets)
32+
moveit_planning_scene_rviz_plugin_core Qt${QT_VERSION_MAJOR}::Widgets)
3133
ament_target_dependencies(moveit_planning_scene_rviz_plugin pluginlib
3234
rviz_ogre_vendor)
3335
target_include_directories(moveit_planning_scene_rviz_plugin

moveit_ros/visualization/rviz_plugin_render_tools/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
2+
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
3+
14
set(HEADERS
25
include/moveit/rviz_plugin_render_tools/octomap_render.hpp
36
include/moveit/rviz_plugin_render_tools/planning_link_updater.hpp
@@ -24,7 +27,7 @@ add_library(
2427
set_target_properties(moveit_rviz_plugin_render_tools
2528
PROPERTIES VERSION "${${PROJECT_NAME}_VERSION}")
2629

27-
target_link_libraries(moveit_rviz_plugin_render_tools Qt5::Widgets)
30+
target_link_libraries(moveit_rviz_plugin_render_tools Qt${QT_VERSION_MAJOR}::Widgets)
2831

2932
ament_target_dependencies(
3033
moveit_rviz_plugin_render_tools

moveit_setup_assistant/moveit_setup_app_plugins/CMakeLists.txt

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
cmake_minimum_required(VERSION 3.22)
22
project(moveit_setup_app_plugins LANGUAGES CXX)
3+
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Core)
4+
if(Qt${QT_VERSION_MAJOR} STREQUAL "Qt6")
5+
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Test Widgets Core5Compat)
6+
elseif()
7+
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Test Widgets )
8+
endif()
9+
310

411
# Common cmake code applied to all moveit packages
512
find_package(moveit_common REQUIRED)
@@ -17,7 +24,7 @@ find_package(rclcpp REQUIRED)
1724
set(CMAKE_AUTOMOC ON)
1825
add_definitions(-DQT_NO_KEYWORDS)
1926

20-
qt5_wrap_cpp(MOC_FILES include/moveit_setup_app_plugins/launches_widget.hpp
27+
qt_wrap_cpp(MOC_FILES include/moveit_setup_app_plugins/launches_widget.hpp
2128
include/moveit_setup_app_plugins/perception_widget.hpp)
2229

2330
add_library(
@@ -33,9 +40,24 @@ target_include_directories(
3340
moveit_setup_app_plugins
3441
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
3542
$<INSTALL_INTERFACE:include/moveit_setup_app_plugins>)
36-
ament_target_dependencies(
37-
moveit_setup_app_plugins ament_index_cpp moveit_ros_visualization
38-
moveit_setup_framework pluginlib rclcpp)
43+
44+
if(Qt${QT_VERSION_MAJOR} STREQUAL "Qt6")
45+
target_link_libraries(
46+
moveit_setup_app_plugins
47+
PUBLIC ament_index_cpp::ament_index_cpp
48+
moveit_setup_framework::moveit_setup_framework pluginlib::pluginlib
49+
rclcpp::rclcpp
50+
Qt${QT_VERSION_MAJOR}::Widgets
51+
Qt${QT_VERSION_MAJOR}::Core5Compat)
52+
elseif()
53+
target_link_libraries(
54+
moveit_setup_app_plugins
55+
PUBLIC ament_index_cpp::ament_index_cpp
56+
moveit_setup_framework::moveit_setup_framework pluginlib::pluginlib
57+
rclcpp::rclcpp
58+
Qt${QT_VERSION_MAJOR}::Widgets)
59+
endif()
60+
3961

4062
if(BUILD_TESTING)
4163
find_package(ament_cmake_gtest REQUIRED)

moveit_setup_assistant/moveit_setup_assistant/CMakeLists.txt

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,33 @@ find_package(Boost REQUIRED program_options)
1212
find_package(moveit_setup_framework REQUIRED)
1313
find_package(moveit_setup_srdf_plugins REQUIRED)
1414
find_package(pluginlib REQUIRED)
15-
find_package(Qt5Core REQUIRED)
16-
find_package(Qt5Widgets REQUIRED)
1715
find_package(rclcpp REQUIRED)
1816

19-
set(THIS_PACKAGE_INCLUDE_DEPENDS
17+
if(Qt${QT_VERSION_MAJOR} STREQUAL "Qt6")
18+
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Core Core5Compat)
19+
set(THIS_PACKAGE_INCLUDE_DEPENDS
2020
ament_index_cpp
2121
moveit_setup_framework
2222
moveit_setup_srdf_plugins
2323
pluginlib
24-
Qt5Core
25-
Qt5Widgets
24+
Qt${QT_VERSION_MAJOR}Core
25+
Qt${QT_VERSION_MAJOR}Core5Compat
26+
Qt${QT_VERSION_MAJOR}Widgets
2627
rclcpp)
28+
elseif()
29+
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Widgets )
30+
set(THIS_PACKAGE_INCLUDE_DEPENDS
31+
ament_index_cpp
32+
moveit_setup_framework
33+
moveit_setup_srdf_plugins
34+
pluginlib
35+
Qt${QT_VERSION_MAJOR}Core
36+
Qt${QT_VERSION_MAJOR}Widgets
37+
rclcpp)
38+
endif()
39+
40+
41+
2742

2843
# Header files that need Qt Moc pre-processing for use with Qt signals, etc:
2944
set(HEADERS include/moveit_setup_assistant/navigation_widget.hpp
@@ -32,7 +47,7 @@ set(HEADERS include/moveit_setup_assistant/navigation_widget.hpp
3247
set(CMAKE_AUTOMOC ON)
3348
add_definitions(-DQT_NO_KEYWORDS)
3449

35-
qt5_wrap_cpp(MOC_FILES ${HEADERS})
50+
qt_wrap_cpp(MOC_FILES ${HEADERS})
3651

3752
add_executable(
3853
moveit_setup_assistant src/main.cpp src/setup_assistant_widget.cpp

moveit_setup_assistant/moveit_setup_controllers/CMakeLists.txt

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
cmake_minimum_required(VERSION 3.22)
22
project(moveit_setup_controllers LANGUAGES CXX)
3-
3+
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
4+
if(Qt${QT_VERSION_MAJOR} STREQUAL "Qt6")
5+
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Core5Compat)
6+
elseif()
7+
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets )
8+
endif()
49
# Common cmake code applied to all moveit packages
510
find_package(moveit_common REQUIRED)
611
moveit_package()
@@ -16,7 +21,7 @@ find_package(rclcpp REQUIRED)
1621
set(CMAKE_AUTOMOC ON)
1722
add_definitions(-DQT_NO_KEYWORDS)
1823

19-
qt5_wrap_cpp(
24+
qt_wrap_cpp(
2025
MOC_FILES include/moveit_setup_controllers/controller_edit_widget.hpp
2126
include/moveit_setup_controllers/controllers_widget.hpp
2227
include/moveit_setup_controllers/urdf_modifications_widget.hpp)
@@ -36,12 +41,65 @@ add_library(
3641
src/urdf_modifications.cpp
3742
src/urdf_modifications_widget.cpp
3843
${MOC_FILES})
44+
3945
target_include_directories(
4046
moveit_setup_controllers
4147
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
4248
$<INSTALL_INTERFACE:include/moveit_setup_controllers>)
43-
ament_target_dependencies(moveit_setup_controllers ament_index_cpp
44-
moveit_setup_framework pluginlib rclcpp)
49+
50+
if(Qt${QT_VERSION_MAJOR} STREQUAL "Qt6")
51+
target_link_libraries (moveit_setup_controllers PUBLIC
52+
Qt${QT_VERSION_MAJOR}::Widgets
53+
Qt${QT_VERSION_MAJOR}::Core5Compat
54+
ament_index_cpp::ament_index_cpp
55+
rclcpp::rclcpp
56+
pluginlib::pluginlib
57+
moveit_core::moveit_utils
58+
moveit_ros_planning::default_request_adapter_parameters
59+
moveit_ros_planning::default_response_adapter_parameters
60+
moveit_ros_planning::kinematics_parameters
61+
moveit_ros_planning::moveit_collision_plugin_loader
62+
moveit_ros_planning::moveit_constraint_sampler_manager_loader
63+
moveit_ros_planning::moveit_cpp
64+
moveit_ros_planning::moveit_kinematics_plugin_loader
65+
moveit_ros_planning::moveit_plan_execution
66+
moveit_ros_planning::moveit_planning_pipeline
67+
moveit_ros_planning::moveit_planning_pipeline_interfaces
68+
moveit_ros_planning::moveit_planning_scene_monitor
69+
moveit_ros_planning::moveit_rdf_loader
70+
moveit_ros_planning::moveit_robot_model_loader
71+
moveit_ros_planning::moveit_trajectory_execution_manager
72+
moveit_ros_planning::planning_pipeline_parameters
73+
moveit_ros_planning::srdf_publisher_node
74+
moveit_setup_framework::moveit_setup_framework
75+
)
76+
elseif()
77+
target_link_libraries (moveit_setup_controllers PUBLIC
78+
Qt${QT_VERSION_MAJOR}::Widgets
79+
ament_index_cpp::ament_index_cpp
80+
rclcpp::rclcpp
81+
pluginlib::pluginlib
82+
moveit_core::moveit_utils
83+
moveit_ros_planning::default_request_adapter_parameters
84+
moveit_ros_planning::default_response_adapter_parameters
85+
moveit_ros_planning::kinematics_parameters
86+
moveit_ros_planning::moveit_collision_plugin_loader
87+
moveit_ros_planning::moveit_constraint_sampler_manager_loader
88+
moveit_ros_planning::moveit_cpp
89+
moveit_ros_planning::moveit_kinematics_plugin_loader
90+
moveit_ros_planning::moveit_plan_execution
91+
moveit_ros_planning::moveit_planning_pipeline
92+
moveit_ros_planning::moveit_planning_pipeline_interfaces
93+
moveit_ros_planning::moveit_planning_scene_monitor
94+
moveit_ros_planning::moveit_rdf_loader
95+
moveit_ros_planning::moveit_robot_model_loader
96+
moveit_ros_planning::moveit_trajectory_execution_manager
97+
moveit_ros_planning::planning_pipeline_parameters
98+
moveit_ros_planning::srdf_publisher_node
99+
moveit_setup_framework::moveit_setup_framework
100+
)
101+
endif()
102+
45103

46104
if(BUILD_TESTING)
47105
find_package(ament_cmake_gtest REQUIRED)

moveit_setup_assistant/moveit_setup_core_plugins/CMakeLists.txt

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
cmake_minimum_required(VERSION 3.22)
22
project(moveit_setup_core_plugins LANGUAGES CXX)
3+
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
4+
if(Qt${QT_VERSION_MAJOR} STREQUAL "Qt6")
5+
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Core5Compat)
6+
elseif()
7+
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets )
8+
endif()
39

410
# Common cmake code applied to all moveit packages
511
find_package(moveit_common REQUIRED)
@@ -19,7 +25,7 @@ find_package(urdf REQUIRED)
1925
set(CMAKE_AUTOMOC ON)
2026
add_definitions(-DQT_NO_KEYWORDS)
2127

22-
qt5_wrap_cpp(
28+
qt_wrap_cpp(
2329
MOC_FILES include/moveit_setup_core_plugins/start_screen_widget.hpp
2430
include/moveit_setup_core_plugins/configuration_files_widget.hpp
2531
include/moveit_setup_core_plugins/author_information_widget.hpp)
@@ -36,15 +42,29 @@ add_library(
3642
target_include_directories(
3743
${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
3844
$<INSTALL_INTERFACE:include/moveit_setup_core_plugins>)
39-
ament_target_dependencies(
40-
${PROJECT_NAME}
41-
ament_index_cpp
42-
moveit_ros_visualization
43-
moveit_setup_framework
44-
pluginlib
45-
rclcpp
46-
srdfdom
47-
urdf)
45+
if(Qt${QT_VERSION_MAJOR} STREQUAL "Qt6")
46+
target_link_libraries(
47+
${PROJECT_NAME}
48+
PUBLIC ament_index_cpp::ament_index_cpp
49+
pluginlib::pluginlib
50+
rclcpp::rclcpp
51+
srdfdom::srdfdom
52+
urdf::urdf
53+
Qt${QT_VERSION_MAJOR}::Widgets
54+
Qt${QT_VERSION_MAJOR}::Core5Compat
55+
moveit_setup_framework::moveit_setup_framework)
56+
elseif()
57+
target_link_libraries(
58+
${PROJECT_NAME}
59+
PUBLIC ament_index_cpp::ament_index_cpp
60+
pluginlib::pluginlib
61+
rclcpp::rclcpp
62+
srdfdom::srdfdom
63+
urdf::urdf
64+
Qt${QT_VERSION_MAJOR}::Widgets
65+
moveit_setup_framework::moveit_setup_framework)
66+
endif()
67+
4868

4969
install(
5070
TARGETS moveit_setup_core_plugins

0 commit comments

Comments
 (0)