Repository navigation
Fix navmap_rviz_plugin build with Qt5 rviz_common and Qt6 installed #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Butakus
wants to merge
1
commit into
EasyNavigation:rolling
Choose a base branch
from
Butakus:fix_qt5_qt6
base: rolling
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: |
||
| 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 | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
AMENT_PREFIX_PATHis not set or does not containrviz_common(e.g. a build that only passesCMAKE_PREFIX_PATH),find_filegivesRVIZ_COMMON_DEPS_FILE-NOTFOUNDandfile(READ)aborts the configure with "failed to open for reading", which does not say what is wrong. Before this change that case worked.Could it also search
CMAKE_PREFIX_PATH, and when the file is not found skip the read and keep the previous detection (get_target_propertyonrviz_common::rviz_commonafterfind_package(rviz_common))? Something like: