diff --git a/rviz2/CMakeLists.txt b/rviz2/CMakeLists.txt index a0677c212..815df84df 100644 --- a/rviz2/CMakeLists.txt +++ b/rviz2/CMakeLists.txt @@ -18,24 +18,25 @@ find_package(rviz_common REQUIRED) find_package(rviz_ogre_vendor REQUIRED) -find_package(Qt5 REQUIRED COMPONENTS Widgets) +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) # TODO(wjwwood): this block is to setup the windeployqt tool, could be removed later. -if(Qt5_FOUND AND WIN32 AND TARGET Qt5::qmake AND NOT TARGET Qt5::windeployqt) - get_target_property(_qt5_qmake_location Qt5::qmake IMPORTED_LOCATION) +if(Qt${QT_VERSION_MAJOR}_FOUND AND WIN32 AND TARGET Qt${QT_VERSION_MAJOR}::qmake AND NOT TARGET Qt${QT_VERSION_MAJOR}::windeployqt) + get_target_property(_qt_qmake_location Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION) execute_process( - COMMAND "${_qt5_qmake_location}" -query QT_INSTALL_PREFIX + COMMAND "${_qt_qmake_location}" -query QT${QT_VERSION_MAJOR}_INSTALL_PREFIX RESULT_VARIABLE return_code - OUTPUT_VARIABLE qt5_install_prefix + OUTPUT_VARIABLE qt_install_prefix OUTPUT_STRIP_TRAILING_WHITESPACE ) - set(imported_location "${qt5_install_prefix}/bin/windeployqt.exe") + set(imported_location "${qt_install_prefix}/bin/windeployqt.exe") if(EXISTS ${imported_location}) - add_executable(Qt5::windeployqt IMPORTED) + add_executable(Qt${QT_VERSION_MAJOR}::windeployqt IMPORTED) - set_target_properties(Qt5::windeployqt PROPERTIES + set_target_properties(Qt${QT_VERSION_MAJOR}::windeployqt PROPERTIES IMPORTED_LOCATION ${imported_location} ) endif() @@ -48,21 +49,21 @@ target_link_libraries(${PROJECT_NAME} rviz_common::rviz_common rviz_ogre_vendor::OgreMain rviz_ogre_vendor::OgreOverlay - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets ) # TODO(wjwwood): find a way to make this optional or to run without "deploying" the # necessary dlls and stuff to the bin folder. # see: # https://stackoverflow.com/questions/41193584/deploy-all-qt-dependencies-when-building#41199492 -if(TARGET Qt5::windeployqt) +if(TARGET Qt${QT_VERSION_MAJOR}::windeployqt) # execute windeployqt in a tmp directory after build add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_CURRENT_BINARY_DIR}/windeployqt" - COMMAND set PATH=%PATH%$${qt5_install_prefix}/bin + COMMAND set PATH=%PATH%$${qt_install_prefix}/bin COMMAND - Qt5::windeployqt + Qt${QT_VERSION_MAJOR}::windeployqt --dir "${CMAKE_CURRENT_BINARY_DIR}/windeployqt" "$/$" ) diff --git a/rviz_common/CMakeLists.txt b/rviz_common/CMakeLists.txt index 7741c400b..be691674d 100644 --- a/rviz_common/CMakeLists.txt +++ b/rviz_common/CMakeLists.txt @@ -31,7 +31,14 @@ find_package(ament_cmake REQUIRED) # do find_package(rviz_ogre_vendor) first to make sure the custom OGRE is found find_package(rviz_ogre_vendor REQUIRED) -find_package(Qt5 REQUIRED COMPONENTS Widgets) +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) +if(${QT_VERSION} VERSION_LESS 5.15.0) + function(qt_wrap_cpp out) + qt5_wrap_cpp(_sources ${ARGN}) + set("${out}" ${_sources} PARENT_SCOPE) + endfunction() +endif() find_package(geometry_msgs REQUIRED) find_package(pluginlib REQUIRED) @@ -131,7 +138,7 @@ set(rviz_common_headers_to_moc ) foreach(header "${rviz_common_headers_to_moc}") - qt5_wrap_cpp(rviz_common_moc_files "${header}") + qt_wrap_cpp(rviz_common_moc_files "${header}") endforeach() set(rviz_common_source_files @@ -239,7 +246,7 @@ target_link_libraries(rviz_common PUBLIC ${geometry_msgs_TARGETS} message_filters::message_filters pluginlib::pluginlib - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets rclcpp::rclcpp rviz_ogre_vendor::OgreMain rviz_ogre_vendor::OgreOverlay @@ -265,7 +272,7 @@ ament_export_dependencies( geometry_msgs message_filters pluginlib - Qt5 + Qt${QT_VERSION_MAJOR} rclcpp rviz_ogre_vendor rviz_rendering @@ -324,10 +331,10 @@ if(BUILD_TESTING) find_package(ament_cmake_gmock REQUIRED) find_package(ament_cmake_gtest REQUIRED) - qt5_wrap_cpp(rviz_common_test_moc_files test/mock_display.hpp) - qt5_wrap_cpp(rviz_common_test_moc_files test/mock_property_change_receiver.hpp) + qt_wrap_cpp(rviz_common_test_moc_files test/mock_display.hpp) + qt_wrap_cpp(rviz_common_test_moc_files test/mock_property_change_receiver.hpp) - qt5_wrap_cpp(rviz_common_test_frame_manager_moc src/rviz_common/frame_manager.hpp) + qt_wrap_cpp(rviz_common_test_frame_manager_moc src/rviz_common/frame_manager.hpp) ament_add_gmock(display_factory_test test/display_factory_test.cpp @@ -336,7 +343,7 @@ if(BUILD_TESTING) if(TARGET display_factory_test) target_compile_definitions(display_factory_test PUBLIC -D_TEST_PLUGIN_DESCRIPTIONS="${CMAKE_CURRENT_SOURCE_DIR}") - target_link_libraries(display_factory_test rviz_common Qt5::Widgets) + target_link_libraries(display_factory_test rviz_common Qt${QT_VERSION_MAJOR}::Widgets) endif() ament_add_gmock(frame_manager_test @@ -445,7 +452,7 @@ if(BUILD_TESTING) test/mock_property_change_receiver.cpp ${SKIP_DISPLAY_TESTS}) if(TARGET rviz_common_display_test) - target_link_libraries(rviz_common_display_test rviz_common Qt5::Widgets yaml-cpp::yaml-cpp) + target_link_libraries(rviz_common_display_test rviz_common Qt${QT_VERSION_MAJOR}::Widgets yaml-cpp::yaml-cpp) endif() endif() diff --git a/rviz_common/include/rviz_common/properties/ros_topic_property.hpp b/rviz_common/include/rviz_common/properties/ros_topic_property.hpp index cc39bf3fc..4d4558f92 100644 --- a/rviz_common/include/rviz_common/properties/ros_topic_property.hpp +++ b/rviz_common/include/rviz_common/properties/ros_topic_property.hpp @@ -32,6 +32,8 @@ #include +#include // NOLINT: cpplint is unable to handle the include order here + #include "rviz_common/properties/editable_enum_property.hpp" #include "rviz_common/ros_integration/ros_node_abstraction_iface.hpp" #include "rviz_common/visibility_control.hpp" @@ -90,20 +92,20 @@ class RVIZ_COMMON_PUBLIC RosFilteredTopicProperty const QString & default_value = QString(), const QString & message_type = QString(), const QString & description = QString(), - const QRegExp & filter = QRegExp(), + const QRegularExpression & filter = QRegularExpression(), Property * parent = 0, const char * changed_slot = 0, QObject * receiver = 0); void enableFilter(bool enabled); - QRegExp filter() const; + QRegularExpression filter() const; protected Q_SLOTS: void fillTopicList() override; private: - QRegExp filter_; + QRegularExpression filter_; bool filter_enabled_; }; diff --git a/rviz_common/rviz_common-extras.cmake b/rviz_common/rviz_common-extras.cmake index bbaf6efdb..5de5a16c5 100644 --- a/rviz_common/rviz_common-extras.cmake +++ b/rviz_common/rviz_common-extras.cmake @@ -30,4 +30,5 @@ # find package Qt5 because otherwise using the rviz_common::rviz_common # exported target will complain that the Qt5::Widgets target does not exist -find_package(Qt5 REQUIRED QUIET COMPONENTS Widgets) +find_package(QT NAMES Qt6 Qt5 QUIET COMPONENTS Widgets) +find_package(Qt${QT_VERSION_MAJOR} QUIET COMPONENTS Widgets) diff --git a/rviz_common/src/rviz_common/add_display_dialog.cpp b/rviz_common/src/rviz_common/add_display_dialog.cpp index d2c444b23..1fcd52610 100644 --- a/rviz_common/src/rviz_common/add_display_dialog.cpp +++ b/rviz_common/src/rviz_common/add_display_dialog.cpp @@ -47,6 +47,7 @@ #include // NOLINT: cpplint is unable to handle the include order here #include // NOLINT: cpplint is unable to handle the include order here #include // NOLINT: cpplint is unable to handle the include order here +#include // NOLINT: cpplint is unable to handle the include order here #include // NOLINT: cpplint is unable to handle the include order here #include // NOLINT: cpplint is unable to handle the include order here #include // NOLINT: cpplint is unable to handle the include order here @@ -591,7 +592,7 @@ void TopicDisplayWidget::findPlugins(DisplayFactory * factory) // For now, we assume that all types supported by plugins have the form // "/msg/", though in the future zero or more namespaces may be // permitted. - QRegExp delim("/"); + QRegularExpression delim("/"); QStringList topic_type_parts = topic_type.split(delim); if (topic_type_parts.size() == 2) { topic_type = topic_type_parts.at(0) + "/msg/" + topic_type_parts.at(1); diff --git a/rviz_common/src/rviz_common/properties/property_tree_model.cpp b/rviz_common/src/rviz_common/properties/property_tree_model.cpp index 94d05f5fd..dd29b8620 100644 --- a/rviz_common/src/rviz_common/properties/property_tree_model.cpp +++ b/rviz_common/src/rviz_common/properties/property_tree_model.cpp @@ -33,6 +33,7 @@ #include +#include // NOLINT: cpplint is unable to handle the include order here #include // NOLINT: cpplint is unable to handle the include order here #include // NOLINT: cpplint is unable to handle the include order here diff --git a/rviz_common/src/rviz_common/properties/ros_topic_property.cpp b/rviz_common/src/rviz_common/properties/ros_topic_property.cpp index 9a813931e..3ee30dc62 100644 --- a/rviz_common/src/rviz_common/properties/ros_topic_property.cpp +++ b/rviz_common/src/rviz_common/properties/ros_topic_property.cpp @@ -95,7 +95,7 @@ RosFilteredTopicProperty::RosFilteredTopicProperty( const QString & default_value, const QString & message_type, const QString & description, - const QRegExp & filter, + const QRegularExpression & filter, Property * parent, const char * changed_slot, QObject * receiver) @@ -111,7 +111,7 @@ void RosFilteredTopicProperty::enableFilter(bool enabled) fillTopicList(); } -QRegExp RosFilteredTopicProperty::filter() const +QRegularExpression RosFilteredTopicProperty::filter() const { return filter_; } diff --git a/rviz_common/src/rviz_common/tool_manager.cpp b/rviz_common/src/rviz_common/tool_manager.cpp index 2ebb8f466..96f82698d 100644 --- a/rviz_common/src/rviz_common/tool_manager.cpp +++ b/rviz_common/src/rviz_common/tool_manager.cpp @@ -36,7 +36,7 @@ #include // NOLINT: cpplint is unable to handle the include order here #include // NOLINT: cpplint is unable to handle the include order here -#include // NOLINT: cpplint is unable to handle the include order here +#include // NOLINT: cpplint is unable to handle the include order here #include "rviz_common/logging.hpp" @@ -53,7 +53,7 @@ using rviz_common::properties::PropertyTreeModel; QString addSpaceToCamelCase(QString input) { - QRegExp re = QRegExp("([A-Z])([a-z]*)"); + QRegularExpression re = QRegularExpression("([A-Z])([a-z]*)"); input.replace(re, " \\1\\2"); return input.trimmed(); } diff --git a/rviz_common/src/rviz_common/visualization_frame.cpp b/rviz_common/src/rviz_common/visualization_frame.cpp index 61ed0c3b7..c5e1d78c4 100644 --- a/rviz_common/src/rviz_common/visualization_frame.cpp +++ b/rviz_common/src/rviz_common/visualization_frame.cpp @@ -43,6 +43,7 @@ #include #include +#include // NOLINT cpplint cannot handle include order here #include // NOLINT cpplint cannot handle include order here #include // NOLINT cpplint cannot handle include order here #include // NOLINT cpplint cannot handle include order here @@ -263,7 +264,7 @@ void VisualizationFrame::initialize( QWidget * central_widget = new QWidget(this); QHBoxLayout * central_layout = new QHBoxLayout; central_layout->setSpacing(0); - central_layout->setMargin(0); + central_layout->setContentsMargins(0, 0, 0, 0); render_panel_ = new RenderPanel(central_widget); diff --git a/rviz_default_plugins/CMakeLists.txt b/rviz_default_plugins/CMakeLists.txt index 1bdc96b17..df514d1f4 100644 --- a/rviz_default_plugins/CMakeLists.txt +++ b/rviz_default_plugins/CMakeLists.txt @@ -57,7 +57,14 @@ find_package(rviz_common REQUIRED) find_package(rviz_rendering REQUIRED) find_package(rviz_ogre_vendor REQUIRED) -find_package(Qt5 REQUIRED COMPONENTS Widgets Test) +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Test Widgets) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Test Widgets) +if(${QT_VERSION} VERSION_LESS 5.15.0) + function(qt_wrap_cpp out) + qt5_wrap_cpp(_sources ${ARGN}) + set("${out}" ${_sources} PARENT_SCOPE) + endfunction() +endif() find_package(geometry_msgs REQUIRED) @@ -135,7 +142,7 @@ set(rviz_default_plugins_headers_to_moc ) foreach(header "${rviz_default_plugins_headers_to_moc}") - qt5_wrap_cpp(rviz_default_plugins_moc_files "${header}") + qt_wrap_cpp(rviz_default_plugins_moc_files "${header}") endforeach() set(rviz_default_plugins_source_files @@ -240,7 +247,6 @@ add_library(rviz_default_plugins SHARED target_include_directories(rviz_default_plugins PUBLIC $ $ - ${Qt5Widgets_INCLUDE_DIRS} ) target_link_libraries(rviz_default_plugins PUBLIC @@ -251,6 +257,7 @@ target_link_libraries(rviz_default_plugins PUBLIC ${map_msgs_TARGETS} ${nav_msgs_TARGETS} point_cloud_transport::point_cloud_transport + Qt${QT_VERSION_MAJOR}::Widgets rclcpp::rclcpp rviz_common::rviz_common rviz_ogre_vendor::OgreMain @@ -289,6 +296,7 @@ ament_export_dependencies( map_msgs nav_msgs point_cloud_transport + Qt${QT_VERSION_MAJOR} rclcpp rviz_common rviz_ogre_vendor @@ -365,7 +373,7 @@ if(BUILD_TESTING) target_link_libraries(fps_view_controller_test ${TEST_FIXTURE_WITH_MOCK_LIBRARIES} rviz_default_plugins - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets ogre_testing_environment ) endif() @@ -402,7 +410,12 @@ if(BUILD_TESTING) ${SKIP_DISPLAY_TESTS}) if(TARGET image_display_test) target_include_directories(image_display_test PRIVATE test) - target_link_libraries(image_display_test ${TEST_FIXTURE_WITH_MOCK_LIBRARIES} Qt5::Widgets rviz_default_plugins ogre_testing_environment) + target_link_libraries(image_display_test + ${TEST_FIXTURE_WITH_MOCK_LIBRARIES} + Qt${QT_VERSION_MAJOR}::Widgets + rviz_default_plugins + ogre_testing_environment + ) endif() add_library(marker_messages STATIC test/rviz_default_plugins/displays/marker/marker_messages.cpp) @@ -495,7 +508,7 @@ if(BUILD_TESTING) target_include_directories(orbit_view_controller_test PRIVATE test) target_link_libraries(orbit_view_controller_test ${TEST_FIXTURE_WITH_MOCK_LIBRARIES} - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets rviz_default_plugins ogre_testing_environment ) @@ -509,7 +522,7 @@ if(BUILD_TESTING) target_include_directories(ortho_view_controller_test PRIVATE test) target_link_libraries(ortho_view_controller_test ${TEST_FIXTURE_WITH_MOCK_LIBRARIES} - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets rviz_default_plugins ogre_testing_environment ) @@ -602,7 +615,7 @@ if(BUILD_TESTING) target_include_directories(point_cloud_transformers_test PRIVATE test) target_link_libraries(point_cloud_transformers_test ${TEST_FIXTURE_WITH_MOCK_LIBRARIES} - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets rviz_default_plugins pointcloud_messages ogre_testing_environment @@ -659,7 +672,7 @@ if(BUILD_TESTING) target_link_libraries(robot_test ${TEST_FIXTURE_WITH_MOCK_LIBRARIES} resource_retriever::resource_retriever - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets rviz_default_plugins ogre_testing_environment ) @@ -696,7 +709,7 @@ if(BUILD_TESTING) target_include_directories(xy_orbit_view_controller_test PRIVATE test) target_link_libraries(xy_orbit_view_controller_test ${TEST_FIXTURE_WITH_MOCK_LIBRARIES} - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets rviz_default_plugins ogre_testing_environment ) @@ -773,7 +786,11 @@ if(BUILD_TESTING) endif() add_library(point_cloud_common_page_object STATIC test/rviz_default_plugins/page_objects/point_cloud_common_page_object.cpp) - target_link_libraries(point_cloud_common_page_object PRIVATE Qt5::Test rviz_visual_testing_framework::rviz_visual_testing_framework) + target_link_libraries(point_cloud_common_page_object + PRIVATE + Qt${QT_VERSION_MAJOR}::Test + rviz_visual_testing_framework::rviz_visual_testing_framework + ) ament_add_gtest(camera_display_visual_test test/rviz_default_plugins/displays/camera/camera_display_visual_test.cpp @@ -787,7 +804,7 @@ if(BUILD_TESTING) rclcpp::rclcpp ${sensor_msgs_TARGETS} ${std_msgs_TARGETS} - Qt5::Test + Qt${QT_VERSION_MAJOR}::Test ${geometry_msgs_TARGETS} tf2::tf2 point_cloud_common_page_object @@ -830,7 +847,7 @@ if(BUILD_TESTING) target_include_directories(fluid_pressure_display_visual_test PRIVATE test) target_link_libraries(fluid_pressure_display_visual_test rviz_visual_testing_framework::rviz_visual_testing_framework - Qt5::Test + Qt${QT_VERSION_MAJOR}::Test rclcpp::rclcpp pointcloud_messages point_cloud_common_page_object @@ -845,7 +862,7 @@ if(BUILD_TESTING) if(TARGET grid_display_visual_test) target_include_directories(grid_display_visual_test PRIVATE test) target_link_libraries(grid_display_visual_test - Qt5::Test + Qt${QT_VERSION_MAJOR}::Test rviz_visual_testing_framework::rviz_visual_testing_framework ) endif() @@ -870,7 +887,7 @@ if(BUILD_TESTING) if(TARGET illuminance_display_visual_test) target_include_directories(illuminance_display_visual_test PRIVATE test) target_link_libraries(illuminance_display_visual_test - Qt5::Test + Qt${QT_VERSION_MAJOR}::Test rviz_visual_testing_framework::rviz_visual_testing_framework pointcloud_messages point_cloud_common_page_object @@ -885,7 +902,7 @@ if(BUILD_TESTING) if(TARGET image_display_visual_test) target_include_directories(image_display_visual_test PRIVATE test) target_link_libraries(image_display_visual_test - Qt5::Test + Qt${QT_VERSION_MAJOR}::Test rviz_visual_testing_framework::rviz_visual_testing_framework rclcpp::rclcpp ${sensor_msgs_TARGETS} @@ -901,7 +918,7 @@ if(BUILD_TESTING) target_include_directories(interactive_marker_namespace_property_test PRIVATE test) target_link_libraries(interactive_marker_namespace_property_test rviz_default_plugins - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets ogre_testing_environment ) endif() @@ -914,13 +931,17 @@ if(BUILD_TESTING) target_include_directories(laser_scan_display_visual_test PRIVATE test) target_link_libraries(laser_scan_display_visual_test rviz_visual_testing_framework::rviz_visual_testing_framework - Qt5::Test + Qt${QT_VERSION_MAJOR}::Test point_cloud_common_page_object ) endif() add_library(marker_display_page_object STATIC test/rviz_default_plugins/page_objects/marker_display_page_object.cpp) - target_link_libraries(marker_display_page_object PRIVATE Qt5::Widgets rviz_visual_testing_framework::rviz_visual_testing_framework) + target_link_libraries(marker_display_page_object + PRIVATE + Qt${QT_VERSION_MAJOR}::Widgets + rviz_visual_testing_framework::rviz_visual_testing_framework + ) ament_add_gtest(map_display_visual_test test/rviz_default_plugins/displays/map/map_display_visual_test.cpp @@ -931,7 +952,7 @@ if(BUILD_TESTING) target_include_directories(map_display_visual_test PRIVATE test) target_link_libraries(map_display_visual_test rviz_visual_testing_framework::rviz_visual_testing_framework - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets rclcpp::rclcpp ${std_msgs_TARGETS} ${geometry_msgs_TARGETS} @@ -950,7 +971,7 @@ if(BUILD_TESTING) target_include_directories(marker_array_display_visual_test PRIVATE test) target_link_libraries(marker_array_display_visual_test rviz_visual_testing_framework::rviz_visual_testing_framework - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets rclcpp::rclcpp ${std_msgs_TARGETS} ${visualization_msgs_TARGETS} @@ -966,7 +987,7 @@ if(BUILD_TESTING) target_include_directories(marker_display_visual_test PRIVATE test) target_link_libraries(marker_display_visual_test rviz_visual_testing_framework::rviz_visual_testing_framework - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets rclcpp::rclcpp ${std_msgs_TARGETS} ${visualization_msgs_TARGETS} @@ -983,7 +1004,7 @@ if(BUILD_TESTING) target_include_directories(odometry_display_visual_test PRIVATE test) target_link_libraries(odometry_display_visual_test rviz_visual_testing_framework::rviz_visual_testing_framework - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets rclcpp::rclcpp ${std_msgs_TARGETS} ${geometry_msgs_TARGETS} @@ -1000,7 +1021,7 @@ if(BUILD_TESTING) if(TARGET path_display_visual_test) target_include_directories(path_display_visual_test PRIVATE test) target_link_libraries(path_display_visual_test - Qt5::Test + Qt${QT_VERSION_MAJOR}::Test rviz_visual_testing_framework::rviz_visual_testing_framework rclcpp::rclcpp ${std_msgs_TARGETS} @@ -1018,7 +1039,7 @@ if(BUILD_TESTING) target_include_directories(point_display_visual_test PRIVATE test) target_link_libraries(point_display_visual_test rviz_visual_testing_framework::rviz_visual_testing_framework - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets ${geometry_msgs_TARGETS} rclcpp::rclcpp ${std_msgs_TARGETS} @@ -1032,7 +1053,7 @@ if(BUILD_TESTING) if(TARGET point_cloud_display_visual_test) target_include_directories(point_cloud_display_visual_test PRIVATE test) target_link_libraries(point_cloud_display_visual_test - Qt5::Test + Qt${QT_VERSION_MAJOR}::Test rviz_visual_testing_framework::rviz_visual_testing_framework ${geometry_msgs_TARGETS} tf2::tf2 @@ -1050,7 +1071,7 @@ if(BUILD_TESTING) if(TARGET point_cloud2_display_visual_test) target_include_directories(point_cloud2_display_visual_test PRIVATE test) target_link_libraries(point_cloud2_display_visual_test - Qt5::Test + Qt${QT_VERSION_MAJOR}::Test rviz_visual_testing_framework::rviz_visual_testing_framework pointcloud_messages point_cloud_common_page_object @@ -1058,7 +1079,11 @@ if(BUILD_TESTING) endif() add_library(pose_display_page_object STATIC test/rviz_default_plugins/page_objects/pose_display_page_object.cpp) - target_link_libraries(pose_display_page_object PRIVATE Qt5::Widgets rviz_visual_testing_framework::rviz_visual_testing_framework) + target_link_libraries(pose_display_page_object + PRIVATE + Qt${QT_VERSION_MAJOR}::Widgets + rviz_visual_testing_framework::rviz_visual_testing_framework + ) ament_add_gtest(pose_array_display_visual_test test/rviz_default_plugins/displays/pose_array/pose_array_display_visual_test.cpp @@ -1069,7 +1094,7 @@ if(BUILD_TESTING) target_include_directories(pose_array_display_visual_test PRIVATE test) target_link_libraries(pose_array_display_visual_test rviz_visual_testing_framework::rviz_visual_testing_framework - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets rclcpp::rclcpp ${std_msgs_TARGETS} ${geometry_msgs_TARGETS} @@ -1085,7 +1110,7 @@ if(BUILD_TESTING) target_include_directories(pose_display_visual_test PRIVATE test) target_link_libraries(pose_display_visual_test rviz_visual_testing_framework::rviz_visual_testing_framework - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets ${geometry_msgs_TARGETS} rclcpp::rclcpp ${std_msgs_TARGETS} @@ -1102,7 +1127,7 @@ if(BUILD_TESTING) target_include_directories(pose_with_covariance_display_visual_test PRIVATE test) target_link_libraries(pose_with_covariance_display_visual_test rviz_visual_testing_framework::rviz_visual_testing_framework - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets ${geometry_msgs_TARGETS} rclcpp::rclcpp ${std_msgs_TARGETS} @@ -1119,7 +1144,7 @@ if(BUILD_TESTING) target_include_directories(range_display_visual_test PRIVATE test) target_link_libraries(range_display_visual_test rviz_visual_testing_framework::rviz_visual_testing_framework - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets ) endif() @@ -1130,7 +1155,7 @@ if(BUILD_TESTING) if(TARGET relative_humidity_display_visual_test) target_include_directories(relative_humidity_display_visual_test PRIVATE test) target_link_libraries(relative_humidity_display_visual_test - Qt5::Test + Qt${QT_VERSION_MAJOR}::Test rviz_visual_testing_framework::rviz_visual_testing_framework point_cloud_common_page_object ) @@ -1156,7 +1181,7 @@ if(BUILD_TESTING) if(TARGET temperature_display_visual_test) target_include_directories(temperature_display_visual_test PRIVATE test) target_link_libraries(temperature_display_visual_test - Qt5::Test + Qt${QT_VERSION_MAJOR}::Test rviz_visual_testing_framework::rviz_visual_testing_framework point_cloud_common_page_object ) @@ -1171,7 +1196,7 @@ if(BUILD_TESTING) target_include_directories(tf_display_visual_test PRIVATE test) target_link_libraries(tf_display_visual_test rviz_visual_testing_framework::rviz_visual_testing_framework - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets ) endif() @@ -1199,7 +1224,7 @@ if(BUILD_TESTING) target_include_directories(wrench_display_visual_test PRIVATE test) target_link_libraries(wrench_display_visual_test rviz_visual_testing_framework::rviz_visual_testing_framework - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets ) endif() endif() diff --git a/rviz_default_plugins/rviz_default_plugins-extras.cmake b/rviz_default_plugins/rviz_default_plugins-extras.cmake index 0daa129c2..5e73d681a 100644 --- a/rviz_default_plugins/rviz_default_plugins-extras.cmake +++ b/rviz_default_plugins/rviz_default_plugins-extras.cmake @@ -29,4 +29,5 @@ # find package Qt5 because otherwise using the rviz_default_plugins::rviz_default_plugins # exported target will complain that the Qt5::Widgets target does not exist -find_package(Qt5 REQUIRED QUIET COMPONENTS Widgets) +find_package(QT NAMES Qt6 Qt5 QUIET COMPONENTS Widgets) +find_package(Qt${QT_VERSION_MAJOR} QUIET COMPONENTS Widgets) diff --git a/rviz_default_plugins/src/rviz_default_plugins/displays/depth_cloud/depth_cloud_display.cpp b/rviz_default_plugins/src/rviz_default_plugins/displays/depth_cloud/depth_cloud_display.cpp index 18ae173aa..6a42c41c1 100644 --- a/rviz_default_plugins/src/rviz_default_plugins/displays/depth_cloud/depth_cloud_display.cpp +++ b/rviz_default_plugins/src/rviz_default_plugins/displays/depth_cloud/depth_cloud_display.cpp @@ -33,7 +33,7 @@ #include #include -#include +#include #include #include @@ -81,8 +81,8 @@ DepthCloudDisplay::DepthCloudDisplay() { ml_depth_data_ = std::make_unique(); // Depth map properties - QRegExp depth_filter("depth"); - depth_filter.setCaseSensitivity(Qt::CaseInsensitive); + QRegularExpression depth_filter("depth"); + depth_filter.setPatternOptions(QRegularExpression::CaseInsensitiveOption); reliability_policy_property_ = new rviz_common::properties::EditableEnumProperty( "Reliability Policy", @@ -119,8 +119,8 @@ DepthCloudDisplay::DepthCloudDisplay() depth_transport_property_->setStdString("raw"); // color image properties - QRegExp color_filter("color|rgb|bgr|gray|mono"); - color_filter.setCaseSensitivity(Qt::CaseInsensitive); + QRegularExpression color_filter("color|rgb|bgr|gray|mono"); + color_filter.setPatternOptions(QRegularExpression::CaseInsensitiveOption); color_topic_property_ = new rviz_common::properties::RosFilteredTopicProperty( "Color Image Topic", "", diff --git a/rviz_rendering/CMakeLists.txt b/rviz_rendering/CMakeLists.txt index b95e0a30e..e69157996 100644 --- a/rviz_rendering/CMakeLists.txt +++ b/rviz_rendering/CMakeLists.txt @@ -33,7 +33,14 @@ find_package(ament_cmake_ros REQUIRED) find_package(rviz_ogre_vendor REQUIRED) find_package(rviz_assimp_vendor REQUIRED) -find_package(Qt5 REQUIRED COMPONENTS Widgets) +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) +if(${QT_VERSION} VERSION_LESS 5.15.0) + function(qt_wrap_cpp out) + qt5_wrap_cpp(_sources ${ARGN}) + set("${out}" ${_sources} PARENT_SCOPE) + endfunction() +endif() find_package(ament_index_cpp REQUIRED) find_package(eigen3_cmake_module REQUIRED) @@ -41,29 +48,29 @@ find_package(Eigen3 REQUIRED) find_package(resource_retriever REQUIRED) # TODO(wjwwood): this block is to setup the windeployqt tool, could be removed later. -if(Qt5_FOUND AND WIN32 AND TARGET Qt5::qmake AND NOT TARGET Qt5::windeployqt) - get_target_property(_qt5_qmake_location Qt5::qmake IMPORTED_LOCATION) +if(Qt${QT_VERSION_MAJOR}_FOUND AND WIN32 AND TARGET Qt${QT_VERSION_MAJOR}::qmake AND NOT TARGET Qt${QT_VERSION_MAJOR}::windeployqt) + get_target_property(_qt_qmake_location Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION) execute_process( - COMMAND "${_qt5_qmake_location}" -query QT_INSTALL_PREFIX + COMMAND "${_qt_qmake_location}" -query Qt${QT_VERSION_MAJOR}_INSTALL_PREFIX RESULT_VARIABLE return_code - OUTPUT_VARIABLE qt5_install_prefix + OUTPUT_VARIABLE qt_install_prefix OUTPUT_STRIP_TRAILING_WHITESPACE ) - set(imported_location "${qt5_install_prefix}/bin/windeployqt.exe") + set(imported_location "${qt_install_prefix}/bin/windeployqt.exe") if(EXISTS ${imported_location}) - add_executable(Qt5::windeployqt IMPORTED) + add_executable(Qt${QT_VERSION_MAJOR}::windeployqt IMPORTED) - set_target_properties(Qt5::windeployqt PROPERTIES + set_target_properties(Qt${QT_VERSION_MAJOR}::windeployqt PROPERTIES IMPORTED_LOCATION ${imported_location} ) endif() endif() # These need to be added in the add_library() call -qt5_wrap_cpp(rviz_rendering_moc_files include/rviz_rendering/render_window.hpp) +qt_wrap_cpp(rviz_rendering_moc_files include/rviz_rendering/render_window.hpp) add_library(rviz_rendering SHARED ${rviz_rendering_moc_files} @@ -100,7 +107,7 @@ add_library(rviz_rendering SHARED ) target_link_libraries(rviz_rendering PUBLIC - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets rviz_ogre_vendor::OgreMain rviz_ogre_vendor::OgreOverlay ) @@ -128,7 +135,7 @@ target_compile_definitions(rviz_rendering PRIVATE "RVIZ_RENDERING_BUILDING_LIBRA ament_export_dependencies( Eigen3 - Qt5 + Qt${QT_VERSION_MAJOR} rviz_ogre_vendor ) @@ -194,7 +201,7 @@ if(BUILD_TESTING) rviz_ogre_vendor::OgreMain rviz_rendering rviz_rendering_test_utils - Qt5::Widgets # explicitly do this for include directories (not necessary for external use) + Qt${QT_VERSION_MAJOR}::Widgets # explicitly do this for include directories (not necessary for external use) ) endif() @@ -206,7 +213,7 @@ if(BUILD_TESTING) rviz_ogre_vendor::OgreMain rviz_rendering rviz_rendering_test_utils - Qt5::Widgets # explicitly do this for include directories (not necessary for external use) + Qt${QT_VERSION_MAJOR}::Widgets # explicitly do this for include directories (not necessary for external use) ) endif() @@ -218,7 +225,7 @@ if(BUILD_TESTING) rviz_ogre_vendor::OgreMain rviz_rendering rviz_rendering_test_utils - Qt5::Widgets # explicitly do this for include directories (not necessary for external use) + Qt${QT_VERSION_MAJOR}::Widgets # explicitly do this for include directories (not necessary for external use) ) endif() @@ -230,7 +237,7 @@ if(BUILD_TESTING) rviz_ogre_vendor::OgreMain rviz_rendering rviz_rendering_test_utils - Qt5::Widgets # explicitly do this for include directories (not necessary for external use) + Qt${QT_VERSION_MAJOR}::Widgets # explicitly do this for include directories (not necessary for external use) ) endif() @@ -242,7 +249,7 @@ if(BUILD_TESTING) rviz_ogre_vendor::OgreMain rviz_rendering rviz_rendering_test_utils - Qt5::Widgets # explicitly do this for include directories (not necessary for external use) + Qt${QT_VERSION_MAJOR}::Widgets # explicitly do this for include directories (not necessary for external use) ) endif() @@ -254,7 +261,7 @@ if(BUILD_TESTING) rviz_ogre_vendor::OgreMain rviz_rendering rviz_rendering_test_utils - Qt5::Widgets # explicitly do this for include directories (not necessary for external use) + Qt${QT_VERSION_MAJOR}::Widgets # explicitly do this for include directories (not necessary for external use) ) endif() @@ -267,7 +274,7 @@ if(BUILD_TESTING) rviz_ogre_vendor::OgreOverlay rviz_rendering rviz_rendering_test_utils - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets ) endif() @@ -279,7 +286,7 @@ if(BUILD_TESTING) rviz_ogre_vendor::OgreMain rviz_rendering rviz_rendering_test_utils - Qt5::Widgets # explicitly do this for include directories (not necessary for external use) + Qt${QT_VERSION_MAJOR}::Widgets # explicitly do this for include directories (not necessary for external use) ) endif() @@ -291,7 +298,7 @@ if(BUILD_TESTING) rviz_ogre_vendor::OgreMain rviz_rendering rviz_rendering_test_utils - Qt5::Widgets # explicitly do this for include directories (not necessary for external use) + Qt${QT_VERSION_MAJOR}::Widgets # explicitly do this for include directories (not necessary for external use) ) endif() @@ -303,7 +310,7 @@ if(BUILD_TESTING) rviz_ogre_vendor::OgreMain rviz_rendering rviz_rendering_test_utils - Qt5::Widgets # explicitly do this for include directories (not necessary for external use) + Qt${QT_VERSION_MAJOR}::Widgets # explicitly do this for include directories (not necessary for external use) ) endif() @@ -315,7 +322,7 @@ if(BUILD_TESTING) rviz_ogre_vendor::OgreMain rviz_rendering rviz_rendering_test_utils - Qt5::Widgets # explicitly do this for include directories (not necessary for external use) + Qt${QT_VERSION_MAJOR}::Widgets # explicitly do this for include directories (not necessary for external use) ) endif() @@ -327,7 +334,7 @@ if(BUILD_TESTING) rviz_ogre_vendor::OgreMain rviz_rendering rviz_rendering_test_utils - Qt5::Widgets # explicitly do this for include directories (not necessary for external use) + Qt${QT_VERSION_MAJOR}::Widgets # explicitly do this for include directories (not necessary for external use) ) endif() endif() diff --git a/rviz_rendering/rviz_rendering-extras.cmake b/rviz_rendering/rviz_rendering-extras.cmake index d665e3765..af934a9a3 100644 --- a/rviz_rendering/rviz_rendering-extras.cmake +++ b/rviz_rendering/rviz_rendering-extras.cmake @@ -30,4 +30,5 @@ # find package Qt5 because otherwise using the rviz_rendering::rviz_rendering # exported target will complain that the Qt5::Widgets target does not exist -find_package(Qt5 REQUIRED QUIET COMPONENTS Widgets) +find_package(QT NAMES Qt6 Qt5 QUIET COMPONENTS Widgets) +find_package(Qt${QT_VERSION_MAJOR} QUIET COMPONENTS Widgets) diff --git a/rviz_rendering_tests/CMakeLists.txt b/rviz_rendering_tests/CMakeLists.txt index 3b593ddc6..a19977642 100644 --- a/rviz_rendering_tests/CMakeLists.txt +++ b/rviz_rendering_tests/CMakeLists.txt @@ -32,7 +32,14 @@ find_package(ament_cmake REQUIRED) if(BUILD_TESTING) # do find_package(rviz_ogre_vendor) first to make sure the custom OGRE is found find_package(rviz_ogre_vendor REQUIRED) - find_package(Qt5 REQUIRED COMPONENTS Widgets) + find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) + find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) + if(${QT_VERSION} VERSION_LESS 5.15.0) + function(qt_wrap_cpp out) + qt5_wrap_cpp(_sources ${ARGN}) + set("${out}" ${_sources} PARENT_SCOPE) + endfunction() + endif() find_package(rviz_rendering REQUIRED) find_package(resource_retriever REQUIRED) diff --git a/rviz_visual_testing_framework/CMakeLists.txt b/rviz_visual_testing_framework/CMakeLists.txt index f393ec727..2ffa5c9b4 100644 --- a/rviz_visual_testing_framework/CMakeLists.txt +++ b/rviz_visual_testing_framework/CMakeLists.txt @@ -25,7 +25,8 @@ endif() find_package(ament_cmake REQUIRED) find_package(geometry_msgs REQUIRED) -find_package(Qt5 REQUIRED COMPONENTS Widgets Test) +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Test Widgets) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Test Widgets) find_package(rclcpp REQUIRED) find_package(rcutils REQUIRED) find_package(rviz_common REQUIRED) @@ -39,13 +40,13 @@ find_package(ament_cmake_gtest REQUIRED) ament_find_gtest() # TODO(wjwwood): this block is to setup the windeployqt tool, could be removed later. -if(Qt5_FOUND AND WIN32 AND TARGET Qt5::qmake AND NOT TARGET Qt5::windeployqt) - get_target_property(_qt5_qmake_location Qt5::qmake IMPORTED_LOCATION) +if(Qt${QT_VERSION_MAJOR}_FOUND AND WIN32 AND TARGET Qt${QT_VERSION_MAJOR}::qmake AND NOT TARGET Qt${QT_VERSION_MAJOR}::windeployqt) + get_target_property(_qt_qmake_location Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION) execute_process( - COMMAND "${_qt5_qmake_location}" -query QT_INSTALL_PREFIX + COMMAND "${_qt_qmake_location}" -query QT${QT_VERSION_MAJOR}_INSTALL_PREFIX RESULT_VARIABLE return_code - OUTPUT_VARIABLE qt5_install_prefix + OUTPUT_VARIABLE qt_install_prefix OUTPUT_STRIP_TRAILING_WHITESPACE ) endif() @@ -71,8 +72,8 @@ target_include_directories(rviz_visual_testing_framework target_link_libraries(rviz_visual_testing_framework PUBLIC ${geometry_msgs_TARGETS} - Qt5::Test - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Test + Qt${QT_VERSION_MAJOR}::Widgets rclcpp::rclcpp rcutils::rcutils rviz_common::rviz_common @@ -84,7 +85,18 @@ target_link_libraries(rviz_visual_testing_framework PUBLIC ) # export information to downstream packages -ament_export_dependencies(geometry_msgs Qt5 rclcpp rcutils rviz_common rviz_ogre_vendor rviz_rendering std_msgs tf2 tf2_ros) +ament_export_dependencies( + geometry_msgs + Qt${QT_VERSION_MAJOR} + rclcpp + rcutils + rviz_common + rviz_ogre_vendor + rviz_rendering + std_msgs + tf2 + tf2_ros +) # Export old-style CMake variables ament_export_include_directories("include/${PROJECT_NAME}")