Skip to content

Use qt6 as the default dependency from rosdep#1635

Merged
ahcorde merged 1 commit intorollingfrom
ahcorde/rolling/qt6_default
Dec 8, 2025
Merged

Use qt6 as the default dependency from rosdep#1635
ahcorde merged 1 commit intorollingfrom
ahcorde/rolling/qt6_default

Conversation

@ahcorde
Copy link
Copy Markdown
Contributor

@ahcorde ahcorde commented Dec 3, 2025

Related with #1634

Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>
@ahcorde
Copy link
Copy Markdown
Contributor Author

ahcorde commented Dec 3, 2025

Related PR ros/rosdistro#48855 to bring svg devel package

Copy link
Copy Markdown

@luca-della-vedova luca-della-vedova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks you for the fix!

For reference, I believe the issue was that we export Qt5 as a dependency and call find_package on it:

$ cat /opt/ros/rolling/share/rviz_common/cmake/ament_cmake_export_dependencies-extras.cmake 
# generated from ament_cmake_export_dependencies/cmake/ament_cmake_export_dependencies-extras.cmake.in

set(_exported_dependencies "geometry_msgs;message_filters;pluginlib;Qt5;rclcpp;rviz_ogre_vendor;rviz_rendering;sensor_msgs;std_msgs;std_srvs;tf2;tf2_ros;yaml_cpp_vendor;yaml-cpp")

But on the other hand we find_package for either Qt6 or Qt5, whichever is found first:

$ cat /opt/ros/rolling/share/rviz_common/cmake/rviz_common-extras.cmake 
# 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(QT NAMES Qt6 Qt5 QUIET COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} QUIET COMPONENTS Widgets)

So if Qt6 is installed we end up with a clash where we find both Qt6 and Qt5 and that doesn't really work.
On the other hand, with this PR, the ament_cmake_export_dependencies-extras.cmake becomes the following:

$ cat install/rviz_common/share/rviz_common/cmake/ament_cmake_export_dependencies-extras.cmake 
# generated from ament_cmake_export_dependencies/cmake/ament_cmake_export_dependencies-extras.cmake.in

set(_exported_dependencies "geometry_msgs;message_filters;pluginlib;Qt6;rclcpp;rviz_ogre_vendor;rviz_rendering;sensor_msgs;std_msgs;std_srvs;tf2;tf2_ros;yaml_cpp_vendor;yaml-cpp")

So we will correctly only look for Qt6 (and possibly fallback to Qt5, but I haven't tested that code path).
I wonder if it is an explicit aim to keep supporting Qt5 or not, I haven't tested that path

@ahcorde
Copy link
Copy Markdown
Contributor Author

ahcorde commented Dec 5, 2025

Pulls: #1635
Gist: https://gist.githubusercontent.com/ahcorde/276dbe5df396bdb03ee1f73df82916f5/raw/899c6b81bdd8c422402daf88ae2dac0d8b7a1c91/ros2.repos
BUILD args: --packages-above-and-dependencies rviz2 rviz_common rviz_default_plugins rviz_rendering rviz_rendering_tests rviz_visual_testing_framework
TEST args: --packages-above rviz2 rviz_common rviz_default_plugins rviz_rendering rviz_rendering_tests rviz_visual_testing_framework
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/17698

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@ahcorde
Copy link
Copy Markdown
Contributor Author

ahcorde commented Dec 8, 2025

@ros-pull-request-builder retest this please

1 similar comment
@ahcorde
Copy link
Copy Markdown
Contributor Author

ahcorde commented Dec 8, 2025

@ros-pull-request-builder retest this please

@ahcorde ahcorde merged commit 4784c8c into rolling Dec 8, 2025
2 checks passed
@ahcorde ahcorde deleted the ahcorde/rolling/qt6_default branch December 8, 2025 17:10
@miguelgonrod
Copy link
Copy Markdown

Hi @ahcorde, I'm not sure but apparently this change broke rolling jobs, as they can't find Qt5::Widgets from rqt_gui_cpp
Status: Build Status

Reference Builds

Log Output

rqt_gui_cpp (stderr)
02:55:31 --- stderr: rqt_gui_cpp
02:55:31 CMake Error at /tmp/ws/install_isolated/qt_gui_cpp/share/qt_gui_cpp/cmake/export_qt_gui_cppExport.cmake:61 (set_target_properties):
02:55:31   The link interface of target "qt_gui_cpp::qt_gui_cpp" contains:
02:55:31 
02:55:31     Qt5::Widgets
02:55:31 
02:55:31   but the target was not found.  Possible reasons include:
02:55:31 
02:55:31     * There is a typo in the target name.
02:55:31     * A find_package call is missing for an IMPORTED target.
02:55:31     * An ALIAS target is missing.
02:55:31 
02:55:31 Call Stack (most recent call first):
02:55:31   /tmp/ws/install_isolated/qt_gui_cpp/share/qt_gui_cpp/cmake/ament_cmake_export_targets-extras.cmake:9 (include)
02:55:31   /tmp/ws/install_isolated/qt_gui_cpp/share/qt_gui_cpp/cmake/qt_gui_cppConfig.cmake:41 (include)
02:55:31   CMakeLists.txt:30 (find_package)
02:55:31 
02:55:31 
02:55:31 CMake Generate step failed.  Build files cannot be regenerated correctly.
02:55:31 ---

@ahcorde
Copy link
Copy Markdown
Contributor Author

ahcorde commented Dec 9, 2025

@Timple
Copy link
Copy Markdown

Timple commented Dec 18, 2025

I also had to do this:

# rviz switched to Qt6: https://github.com/ros2/rviz/pull/1635
if(rviz_common_VERSION_MAJOR GREATER_EQUAL 15 AND rviz_common_VERSION_MINOR GREATER_EQUAL 1)
  find_package(Qt6 COMPONENTS Network REQUIRED)
  set(QT_VERSION_MAJOR 6)
else()
  find_package(Qt5 COMPONENTS Network REQUIRED)
  set(QT_VERSION_MAJOR 5)
endif()
...

target_link_libraries(${PROJECT_NAME} PUBLIC
  proj Qt${QT_VERSION_MAJOR}::Network
  etc

I could not rely on finding Qt6 because a users laptop might have both available.

Timple added a commit to nobleo/rviz_satellite that referenced this pull request Dec 18, 2025
Timple added a commit to nobleo/rviz_satellite that referenced this pull request Dec 18, 2025
Timple added a commit to nobleo/rviz_satellite that referenced this pull request Dec 18, 2025
Timple added a commit to nobleo/rviz_satellite that referenced this pull request Dec 18, 2025
nbbrooks added a commit to nbbrooks/moveit2 that referenced this pull request Mar 22, 2026
…case for Jazzy/Kilted with both Qt6 and Qt5, where Qt5 should be picked.
nbbrooks added a commit to moveit/moveit2 that referenced this pull request Mar 23, 2026
* Adopt QT_VERSION_MAJOR approach used in rvzi2

* Start using <depend> check on ROS_DISTRO to conditionally require qt5 or qt6 depending on ROS_DISTRO

* Explicitly prefer Qt6 when Qt6 and Qt5 are both present to work around the default CMake ascending ordering resolving to Qt5.
- For Rolling, Qt6 should be used if both are present
- For Jazzy and Kilted, Qt5 should be used if both are present, but this will not cover that edge case

* Adopt Timple's approach ros2/rviz#1635 (comment) for supporting edge case for Jazzy/Kilted with both Qt6 and Qt5, where Qt5 should be picked.

* Set QT_DIR to fix transitive dependencies that should resolve to Qt6 but incorrectly resolve to Qt5 due to default cmake order resolution
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants