-
Notifications
You must be signed in to change notification settings - Fork 14
Fix ROS2 C++ build with proper ament CMake exports #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit fixes the ROS2/colcon build integration by properly configuring CMake exports for the ament ecosystem. Changes: - Add ament detection when not building as LF subproject - Move install(EXPORT) from lib/CMakeLists.txt to root CMakeLists.txt (required for ament compatibility - must be alongside ament_package()) - Add NAMESPACE to export for proper imported target creation - Add ament_export_targets(), ament_export_include_directories(), and ament_export_libraries() for full ament integration The key insight is that ament's build system requires the export installation and ament_package() to be in the same CMakeLists.txt file. Using namespaced targets (reactor-cpp::reactor-cpp) ensures proper linkage through CMake's imported target mechanism. Related: lf-lang/lingua-franca#2580 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
ce95a94 to
09b9058
Compare
edwardalee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, this was a complicated one! Thanks for fixing.
|
I don't know what prompted this change, but this PR is a regression and problematic in multiple ways.
Could you revert this change as it is a regression and provide a proper fix in a new PR? I am happy to help with finding a fix, but for this I would need to understand the problem first. Also, I would like to ask everyone to stick to proper code reviews and not just blindly trust AI and sign off on PRs because they pass in CI (at least for the scope of this repo). |
|
An alternative is to remove support for ROS altogether. In this PR, I've removed the ROS2 tests, though oddly, the tests remain permanently incomplete with this annotation: |
|
@cmnrd You are right. Upon closer look, these changes are not ideal. A revert PR has been filed in #82. The original problem detected, which occurred in this CI run, was that the ROS2 test failed because: This error led to this PR attempting to fix the problem in CI. It would be really great if you could offer pointers on how to properly fix this problem. Thanks! |
|
A reversal of the LF repo is filed here: lf-lang/lingua-franca#2581. The CI run should show the exact problem that caused the original failure. |

Summary
Fixes the ROS2 C++ build integration by correcting how reactor-cpp exports its CMake configuration for the ament/colcon ecosystem.
Problem
When building LF programs with the ROS2 platform, downstream packages could not find the
reactor-cpplibrary via CMake'sfind_package(reactor-cpp REQUIRED).Root cause: The reactor-cpp library was being built and installed correctly by colcon, but its CMake export configuration wasn't set up properly for the ament/colcon ecosystem:
install(EXPORT ...)command was inlib/CMakeLists.txt, but ament requires it to be in the rootCMakeLists.txtalongsideament_package()for proper integrationNAMESPACE, which meant the generated CMake config file didn't create proper imported targetsChanges
Added ament detection - Detect when building in a colcon/ament environment and set
REACTOR_CPP_USE_AMENTMoved export installation to root CMakeLists.txt - For ament compatibility, the
install(EXPORT ...)must be in the same file asament_package()Added NAMESPACE to exports - Use
NAMESPACE ${LIB_TARGET}::so downstream packages can link viareactor-cpp::reactor-cppAdded proper ament exports:
Related PR
🤖 Generated with Claude Code