autowarefoundation / autoware.universe

https://autowarefoundation.github.io/autoware.universe/
Apache License 2.0
1.01k stars 650 forks source link

Incorrect qt5 includes #3626

Open VRichardJP opened 1 year ago

VRichardJP commented 1 year ago

Checklist

Description

Similarly to eigen include issue described here https://github.com/autowarefoundation/autoware.universe/pull/3615, some qt5 headers are not included properly:

src/universe/autoware.universe/common/bag_time_manager_rviz_plugin/src/bag_time_manager_panel.cpp
19:#include <qt5/QtWidgets/QHBoxLayout>
20:#include <qt5/QtWidgets/QLabel>
21:#include <qt5/QtWidgets/QWidget>

src/universe/autoware.universe/common/bag_time_manager_rviz_plugin/src/bag_time_manager_panel.hpp
20:#include <qt5/QtWidgets/QComboBox>
21:#include <qt5/QtWidgets/QLabel>
22:#include <qt5/QtWidgets/QPushButton>

src/universe/autoware.universe/common/tier4_traffic_light_rviz_plugin/src/traffic_light_publish_panel.hpp
21:#include <qt5/QtWidgets/QComboBox>
22:#include <qt5/QtWidgets/QPushButton>
23:#include <qt5/QtWidgets/QSpinBox>
24:#include <qt5/QtWidgets/QTableWidget>

src/universe/autoware.universe/common/tier4_simulated_clock_rviz_plugin/src/simulated_clock_panel.hpp
20:#include <qt5/QtWidgets/QComboBox>
21:#include <qt5/QtWidgets/QDoubleSpinBox>
22:#include <qt5/QtWidgets/QPushButton>
23:#include <qt5/QtWidgets/QSpinBox>

src/universe/autoware.universe/common/tier4_simulated_clock_rviz_plugin/src/simulated_clock_panel.cpp
19:#include <qt5/QtWidgets/QGridLayout>
20:#include <qt5/QtWidgets/QHBoxLayout>
21:#include <qt5/QtWidgets/QLabel>
22:#include <qt5/QtWidgets/QWidget>

If you generate and check the compile_commands.json of bag_time_manager_rviz_plugin, you will see this:

-isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore

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:

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

stale[bot] commented 1 year ago

This pull request has been automatically marked as stale because it has not had recent activity.

stale[bot] commented 10 months ago

This pull request has been automatically marked as stale because it has not had recent activity.