Fix broken ROS2 C++ build in CI due to ament#2580
Merged
Merged
Conversation
eb01458 to
25cc564
Compare
lsk567
added a commit
to lf-lang/reactor-cpp
that referenced
this pull request
Jan 21, 2026
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>
This commit fixes two issues:
1. ROS2 C++ Build Integration
The ROS2 C++ test was failing because downstream packages could not find
reactor-cpp via find_package(). The root cause was improper CMake export
configuration for the ament/colcon ecosystem.
Changes to reactor-cpp (submodule update):
- Add ament detection when not building as LF subproject
- Move install(EXPORT) to root CMakeLists.txt (required for ament - 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()
Changes to CppRos2PackageGenerator.kt:
- Add HINTS to find_package(reactor-cpp) to locate it in colcon workspace
- Use namespaced target reactor-cpp::reactor-cpp for linking
2. C++ Coverage Collection (pre-existing bug fix)
The coverage extraction step was looking for the wrong directory path:
- Was: test/Cpp/src-gen/reactor-cpp-default/*
- Now: test/Cpp/src-gen/reactor-cpp/*
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
f70e3c9 to
5238187
Compare
edwardalee
approved these changes
Jan 21, 2026
edwardalee
left a comment
Collaborator
There was a problem hiding this comment.
Wow, this was a complicated one. Thanks for fixing!
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Jan 23, 2026
Revert #2580 and drop ROS2 C++ tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the ROS2 C++ build integration by correcting how
reactor-cppexports its CMake configuration for the ament/colcon ecosystem. Also fixes a pre-existing bug in the C++ coverage collection CI step.Problem
The ROS2 C++ test was failing because downstream packages (the generated LF ROS2 packages) could not find the
reactor-cpplibrary via CMake'sfind_package(reactor-cpp REQUIRED).Root cause: The
reactor-cpplibrary was being built and installed correctly by colcon, but its CMake export configuration wasn't set up properly for the ament/colcon ecosystem. Specifically: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 targetsfind_package(reactor-cpp)couldn't locate the package becauseament_auto_find_build_dependencies()doesn't automatically find packages installed in sibling directories of a colcon workspaceFix
Three coordinated changes were needed:
A. reactor-cpp CMakeLists.txt (root):
B. reactor-cpp lib/CMakeLists.txt:
install(EXPORT ...)call (moved to root)C. CppRos2PackageGenerator.kt (LF code generator):
The key insight was that ament's build system requires the export installation and
ament_package()to be in the same CMakeLists.txt file, and using namespaced targets (reactor-cpp::reactor-cpp) ensures proper linkage through CMake's imported target mechanism.Additional Fix: C++ Coverage Collection
Fixed a pre-existing bug in the CI workflow where the coverage extraction step was looking for the wrong directory path:
test/Cpp/src-gen/reactor-cpp-default/*test/Cpp/src-gen/reactor-cpp/*Test plan
🤖 Generated with Claude Code