Skip to content

USE_SCOPED_HEADER_INSTALL_DIR path issues #273

@pele1410

Description

@pele1410

Running ROS2 Jazzy on Ubuntu 24.04.3

We have started migrating to the new include path location by adding USE_SCOPED_HEADER_INSTALL_DIR to our ament_auto_package() calls in our CMakeLists.txt files (ament/ament_cmake#577). This creates a problem when the generated params.hpp header is included in a public installed header that is then included in a downstream package.

Source

Given this package

src/camera/st_ptz_control/include/st/camera/ptz/onvif_ptz.hpp
src/camera/st_ptz_control/include/st/camera/ptz/ptz.hpp

where onvif_ptz.hpp has the line

#include "st/camera/ptz/ptz.hpp"

where ptz.hpp has the line

#include <st_ptz_control/st_ptz_control_params.hpp>

and its CMakeLists (cruft removed):

generate_parameter_library(
  st_ptz_control_params
  src/params.yaml
)

ament_auto_add_library(
  st_ptz_control_component SHARED
  src/ptz.cpp
)

target_link_libraries(
  st_ptz_control_component
  st_ptz_control_params)

ament_auto_package(USE_SCOPED_HEADER_INSTALL_DIR)

This produces installed headers:

/opt/st/core/st_ptz_control
|-- include
|   `-- st_ptz_control
|       |-- st
|       |   `-- camera
|       |       `-- ptz
|       |           |-- commands.hpp -> /workspace/STcore/core/src/camera/st_ptz_control/include/st/camera/ptz/commands.hpp
|       |           |-- onvif_ptz.hpp -> /workspace/STcore/core/src/camera/st_ptz_control/include/st/camera/ptz/onvif_ptz.hpp
|       |           |-- ptz.hpp -> /workspace/STcore/core/src/camera/st_ptz_control/include/st/camera/ptz/ptz.hpp
|       |           `-- visibility_control.hpp -> /workspace/STcore/core/src/camera/st_ptz_control/include/st/camera/ptz/visibility_control.hpp
|       `-- st_ptz_control_params.hpp -> /workspace/STcore/core/build/st_ptz_control/include/st_ptz_control/st_ptz_control_params.hpp

This package is used by a downstream package with the header

src/camera/st_flir/src/flir.hpp

which has the line

#include "st/camera/ptz/onvif_ptz.hpp"

and its package.xml has

  <depend>st_ptz_control</depend>

Issues

As-written, this generates a compilation error in st_flir:

--- stderr: st_flir
In file included from /opt/st/core/st_ptz_control/include/st_ptz_control/st/camera/ptz/onvif_ptz.hpp:3,
                 from /workspace/STcore/core/src/camera/st_flir/src/flir.hpp:3,
                 from /workspace/STcore/core/src/camera/st_flir/src/flir.cpp:1:
/opt/st/core/st_ptz_control/include/st_ptz_control/st/camera/ptz/ptz.hpp:6:10: fatal error: st_ptz_control/st_ptz_control_params.hpp: No such file or directory
    6 | #include <st_ptz_control/st_ptz_control_params.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
gmake[2]: *** [CMakeFiles/st_flir_component.dir/build.make:76: CMakeFiles/st_flir_component.dir/src/flir.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:139: CMakeFiles/st_flir_component.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2
---
Failed   <<< st_flir [0.12s, exited with code 2]

If I modify the include in onvif_ptz.hpp to be just #include <st_ptz_control_params.hpp> then I get a deprecation warning:

--- stderr: st_ptz_control
In file included from /workspace/STcore/core/src/camera/st_ptz_control/include/st/camera/ptz/ptz.hpp:5,
                 from /workspace/STcore/core/src/camera/st_ptz_control/src/ptz.cpp:1:
/workspace/STcore/core/build/st_ptz_control/include/st_ptz_control_params.hpp:1:137: note: ‘#pragma message: #include "st_ptz_control_params.hpp" is deprecated. Use #include <st_ptz_control/st_ptz_control_params.hpp> instead.’
    1 | #pragma message("#include \"st_ptz_control_params.hpp\" is deprecated. Use #include <st_ptz_control/st_ptz_control_params.hpp> instead.")

Which, if I follow the instructions in the deprecation warning, it appears to be a valid path based on the installed header structure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions