These are the headers that are found by find_package(Qt5 ${rviz_QT_VERSION} EXACT REQUIRED Core Widgets). Actually, the find_package and target_link_libraries are not necessary, because rviz_common seems to already bring everything (but that would be another topic).
The point it that none of these includes contains for example <qt5/QtWidgets/QHBoxLayout>. If the compiler can still find the header and compile, it is because gcc implicitly looks in /usr/include/x86_64-linux-gnu/ (which contains qt5/). In this case, it does not cause any harm, because the qt5 headers we want are actually there, but in the case the user has the qt5 library installed somewhere else (or 2 versions), the compiler may find qt5 but not the headers (or pick the wrong one, or mix different versions).
Questions:
which one to prefer between <QtWidgets/QHBoxLayout> and <QHBoxLayout>? Both seem valid
if rviz_common already brings qt5... can we just remove the dependency from all rviz plugins? maybe even from CMakeLists.txt. I think (not test yet) that adding a library with ament_auto_add_library() while rviz_common is marked as <depend> should automatically include and link qt5. Tt would be very minor, just makes the files simpler.
Expected behavior
qt5 headers properly included
Actual behavior
currently only works with qt5 installed once by the package manager
Checklist
Description
Similarly to eigen include issue described here https://github.com/autowarefoundation/autoware.universe/pull/3615, some qt5 headers are not included properly:
If you generate and check the
compile_commands.json
ofbag_time_manager_rviz_plugin
, you will see this:These are the headers that are found by
find_package(Qt5 ${rviz_QT_VERSION} EXACT REQUIRED Core Widgets)
. Actually, thefind_package
andtarget_link_libraries
are not necessary, becauserviz_common
seems to already bring everything (but that would be another topic).The point it that none of these includes contains for example
<qt5/QtWidgets/QHBoxLayout>
. If the compiler can still find the header and compile, it is because gcc implicitly looks in/usr/include/x86_64-linux-gnu/
(which containsqt5/
). In this case, it does not cause any harm, because the qt5 headers we want are actually there, but in the case the user has the qt5 library installed somewhere else (or 2 versions), the compiler may find qt5 but not the headers (or pick the wrong one, or mix different versions).Questions:
<QtWidgets/QHBoxLayout>
and<QHBoxLayout>
? Both seem validrviz_common
already brings qt5... can we just remove the dependency from all rviz plugins? maybe even fromCMakeLists.txt
. I think (not test yet) that adding a library withament_auto_add_library()
whilerviz_common
is marked as<depend>
should automatically include and link qt5. Tt would be very minor, just makes the files simpler.Expected behavior
qt5 headers properly included
Actual behavior
currently only works with qt5 installed once by the package manager
Steps to reproduce
N/A
Versions
No response
Possible causes
No response
Additional context
No response