colcon / colcon-core

Command line tool to build sets of software packages
http://colcon.readthedocs.io
Apache License 2.0
99 stars 44 forks source link

Package includes directory has subdir of subdir of package name #630

Closed jimmychiuSV closed 4 months ago

jimmychiuSV commented 4 months ago

Unsure if this is an intended design or a bug in ROS2 Iron (didn't notice this pattern in Foxy or Humble). The include header file paths for packages are in double subdirectories of the package name. For example sensor_msgs (as installed with the apt package):

/opt/ros/iron/include/sensor_msgs/sensor_msgs instead of /opt/ros/iron/include/sensor_msgs

Similar pattern for my own packages in the install directory of the workspace:

~/workspace/install/<my_package>/include/<my_package>/<my_package> instead of ~/workspace/install/<my_package>/include/<my_package>

cottsay commented 4 months ago

Hi @jimmychiuSV - a few things here.

First, this is intended behavior. Unlike the traditional system packages where all packages are installed to the same prefix, there can be multiple colcon workspaces present on the same machine. Due to the way compilers reference include directory paths, we need to push these headers down by an extra directory and rely on proper CMake use to add the appropriate search path to the compiler arguments. More information on this problem is in the colcon documentation[1].

Second, this behavior is implemented in the packages themselves, and colcon has no control over it. As you've mentioned, the deb packages installed from apt have the same behavior, and colcon isn't involved in the creation of those packages at all. For message packages like sensor_msgs in particular, the include directory was changed in ros2/rosidl#670, which shipped as part of Humble.

If this change is causing problems for your builds, you likely aren't referencing the package correctly in your CMakeLists.txt.

[1] https://colcon.readthedocs.io/en/released/user/overriding-packages.html#install-headers-to-a-unique-include-directory