-
Notifications
You must be signed in to change notification settings - Fork 450
Description
When building gpio_controllers from a clean workspace (or after deleting build/ and install/), the build frequently fails with a missing header error (fatal error: gpio_controllers/gpio_command_controller_parameters.hpp: No such file or directory) in the test file test_load_gpio_command_controller.cpp.
This appears to be a build race condition in CMakeLists.txt. The test_load_gpio_command_controller target does not explicitly link against the main library (gpio_controllers) or the generated parameter library. Consequently, the build system attempts to compile the test before the parameter header generation is complete.
To Reproduce Steps to reproduce the behavior:
-
Clean the workspace: rm -rf build/ install/ log/
-
Build the package from scratch (forcing parallel execution makes it more likely to fail):
colcon build --packages-select gpio_controllers --parallel-workers 8
- Observe the build failure:
/src/ros2_controllers/gpio_controllers/include/gpio_controllers/gpio_command_controller.hpp:30:10: fatal error: gpio_controllers/gpio_command_controller_parameters.hpp: No such file or directory
Expected behavior: The package and its tests should build successfully from a clean state without dependency race conditions.
Environment:
- OS: Linux (Pop!_OS / Ubuntu 24.04 based)
- Version: Rolling
- Build Tool: colcon
Additional context The issue seems to be missing a dependency link in gpio_controllers/CMakeLists.txt.
Currently, the test target is defined as:
ament_add_gmock(
test_load_gpio_command_controller
test/test_load_gpio_command_controller.cpp
)
target_link_libraries(test_load_gpio_command_controller
controller_manager::controller_manager
hardware_interface::hardware_interface
ros2_control_test_assets::ros2_control_test_assets
# MISSING LINK to ${PROJECT_NAME} or gpio_controllers
)Adding gpio_controllers to target_link_libraries for this test target resolves the race condition by enforcing the correct build order.