From 924df512ffc92ea23b190b1f775f9a6e4d197c15 Mon Sep 17 00:00:00 2001 From: Francisco Miguel Moreno Date: Wed, 4 Nov 2026 16:06:08 +0100 Subject: [PATCH 1/2] Fix navmap_rviz_plugin build with Qt5 rviz_common and Qt6 installed --- navmap_rviz_plugin/CMakeLists.txt | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/navmap_rviz_plugin/CMakeLists.txt b/navmap_rviz_plugin/CMakeLists.txt index c57108f..635b467 100644 --- a/navmap_rviz_plugin/CMakeLists.txt +++ b/navmap_rviz_plugin/CMakeLists.txt @@ -3,6 +3,18 @@ project(navmap_rviz_plugin) find_package(ament_cmake REQUIRED) find_package(rclcpp REQUIRED) +# Use the same Qt as rviz (Qt5 up to Kilted, Qt6 from Lyrical): mixing both breaks the plugin. +# Read it from rviz_common's exported dependencies before find_package(rviz_common): a Qt5 rviz +# looks for Qt6 first if installed and then fails to find Qt5, so Qt6 must be disabled. +find_file(RVIZ_COMMON_DEPS_FILE ament_cmake_export_dependencies-extras.cmake + PATHS ENV AMENT_PREFIX_PATH PATH_SUFFIXES share/rviz_common/cmake NO_DEFAULT_PATH) +file(READ "${RVIZ_COMMON_DEPS_FILE}" rviz_common_deps) +if(rviz_common_deps MATCHES "Qt6") + set(qt_major 6) +else() + set(qt_major 5) + set(CMAKE_DISABLE_FIND_PACKAGE_Qt6 TRUE) +endif() find_package(rviz_common REQUIRED) find_package(rviz_rendering REQUIRED) find_package(rviz_default_plugins REQUIRED) @@ -12,14 +24,6 @@ find_package(navmap_ros_interfaces REQUIRED) find_package(navmap_ros REQUIRED) find_package(navmap_core REQUIRED) -# Same Qt as rviz (Qt5 up to Kilted, Qt6 from Lyrical): mixing both breaks loading the plugin. -# Ask rviz_common: other deps (e.g. VTK via PCL) may bring the other Qt along -get_target_property(rviz_common_libs rviz_common::rviz_common INTERFACE_LINK_LIBRARIES) -if("${rviz_common_libs}" MATCHES "Qt6::") - set(qt_major 6) -else() - set(qt_major 5) -endif() find_package(Qt${qt_major} REQUIRED COMPONENTS Widgets) qt_wrap_cpp(NAVMAP_MOC_SRCS From 1ad2a76719475ecd81a7fa1da5834c7778b795dc Mon Sep 17 00:00:00 2001 From: Francisco Miguel Moreno Date: Fri, 6 Nov 2026 11:49:13 +0100 Subject: [PATCH 2/2] Make Qt version find more robust --- navmap_rviz_plugin/CMakeLists.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/navmap_rviz_plugin/CMakeLists.txt b/navmap_rviz_plugin/CMakeLists.txt index 635b467..b8f8a24 100644 --- a/navmap_rviz_plugin/CMakeLists.txt +++ b/navmap_rviz_plugin/CMakeLists.txt @@ -6,10 +6,14 @@ find_package(rclcpp REQUIRED) # Use the same Qt as rviz (Qt5 up to Kilted, Qt6 from Lyrical): mixing both breaks the plugin. # Read it from rviz_common's exported dependencies before find_package(rviz_common): a Qt5 rviz # looks for Qt6 first if installed and then fails to find Qt5, so Qt6 must be disabled. -find_file(RVIZ_COMMON_DEPS_FILE ament_cmake_export_dependencies-extras.cmake - PATHS ENV AMENT_PREFIX_PATH PATH_SUFFIXES share/rviz_common/cmake NO_DEFAULT_PATH) -file(READ "${RVIZ_COMMON_DEPS_FILE}" rviz_common_deps) -if(rviz_common_deps MATCHES "Qt6") +find_file(rviz_common_deps_file ament_cmake_export_dependencies-extras.cmake + PATHS ${CMAKE_PREFIX_PATH} ENV AMENT_PREFIX_PATH PATH_SUFFIXES share/rviz_common/cmake + NO_DEFAULT_PATH NO_CACHE) +if(NOT rviz_common_deps_file) + message(FATAL_ERROR "rviz_common not found in CMAKE_PREFIX_PATH or AMENT_PREFIX_PATH") +endif() +file(READ "${rviz_common_deps_file}" rviz_common_deps) +if(rviz_common_deps MATCHES "[\";]Qt6[\";]") set(qt_major 6) else() set(qt_major 5)