diff --git a/rviz2/CMakeLists.txt b/rviz2/CMakeLists.txt index 8b063c907..2d602f0f3 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 15f5ed9c5..8b93f3643 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) @@ -132,7 +139,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 @@ -240,7 +247,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 @@ -266,7 +273,7 @@ ament_export_dependencies( geometry_msgs message_filters pluginlib - Qt5 + Qt${QT_VERSION_MAJOR} rclcpp rviz_ogre_vendor rviz_rendering @@ -325,10 +332,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 @@ -337,7 +344,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 @@ -446,7 +453,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 ede824a45..8e423065d 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,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 "rviz_common/properties/editable_enum_property.hpp" @@ -92,20 +93,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 e25199813..3b78550d7 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 @@ -592,7 +593,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 a2f7fdfdb..95b372f4f 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 #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 45b510c3e..f1c74ec07 100644 --- a/rviz_common/src/rviz_common/properties/ros_topic_property.cpp +++ b/rviz_common/src/rviz_common/properties/ros_topic_property.cpp @@ -96,7 +96,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) @@ -112,7 +112,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 9c0ac2383..25756c687 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 // NOLINT: cpplint is unable to handle the include order here #include "rviz_common/logging.hpp" @@ -54,7 +54,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 457957ce5..d9a7d57db 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 @@ -264,7 +265,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 63a189b5f..84a6dcce9 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) @@ -137,7 +144,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 @@ -254,6 +261,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 @@ -294,6 +302,7 @@ ament_export_dependencies( map_msgs nav_msgs point_cloud_transport + Qt${QT_VERSION_MAJOR} rclcpp rviz_common rviz_ogre_vendor @@ -370,7 +379,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() @@ -421,7 +430,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) @@ -514,7 +528,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 ) @@ -528,7 +542,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 ) @@ -621,7 +635,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 @@ -678,7 +692,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 ) @@ -715,7 +729,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 ) @@ -792,7 +806,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 @@ -806,7 +824,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 @@ -849,7 +867,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 @@ -864,7 +882,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() @@ -889,7 +907,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 @@ -904,7 +922,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} @@ -920,7 +938,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() @@ -933,13 +951,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 @@ -950,7 +972,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} @@ -969,7 +991,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} @@ -985,7 +1007,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} @@ -1002,7 +1024,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} @@ -1019,7 +1041,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} @@ -1037,7 +1059,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} @@ -1051,7 +1073,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 @@ -1069,7 +1091,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 @@ -1077,7 +1099,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 @@ -1088,7 +1114,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} @@ -1104,7 +1130,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} @@ -1121,7 +1147,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} @@ -1138,7 +1164,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() @@ -1149,7 +1175,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 ) @@ -1175,7 +1201,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 ) @@ -1190,7 +1216,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() @@ -1218,7 +1244,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 d12977c0b..0aa028a50 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 @@ -82,8 +82,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", @@ -120,8 +120,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 884af9be1..74de3e7c1 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 e3d6603e5..d86f45699 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 00fea10e9..c1586c57b 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}")