Skip to content

Fix component registering in subdirectories#3064

Merged
ahcorde merged 2 commits intoros2:rollingfrom
pum1k:fix/component-in-subdirectory
Feb 19, 2026
Merged

Fix component registering in subdirectories#3064
ahcorde merged 2 commits intoros2:rollingfrom
pum1k:fix/component-in-subdirectory

Conversation

@pum1k
Copy link
Contributor

@pum1k pum1k commented Feb 15, 2026

Description

This PR allows using rclcpp_components_register_node and rclcpp_components_register_nodes functions in subdirectories added by add_subdirectory (and other non global scopes). This was done by storing the internal data in a property of the project directory instead of variable.

Fixes: #1698

Is this user-facing behavior change?

Yes, users will be able to use the above mentioned functions inside nested scopes.

Did you use Generative AI?

No

Signed-off-by: pum1k <55055380+pum1k@users.noreply.github.com>
Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with green CI.

i think that the approach of using directory properties on PROJECT_SOURCE_DIR is the right fix to avoid the CMake variable scoping problem cleanly without polluting the cache.

one minor suggestion: would it be worth adding a brief comment in the hook file explaining why properties are used like original problem?

Signed-off-by: pum1k <55055380+pum1k@users.noreply.github.com>
@pum1k
Copy link
Contributor Author

pum1k commented Feb 16, 2026

@fujitatomoya Is this what you meant?

@ahcorde
Copy link
Contributor

ahcorde commented Feb 18, 2026

Pulls: #3064
Gist: https://gist.githubusercontent.com/ahcorde/41da3d924b8795359675fc94caaaa1a5/raw/8fc503931b6a63733ca4324052ac4297a4f01bc0/ros2.repos
BUILD args: --packages-above-and-dependencies rclcpp_components
TEST args: --packages-above rclcpp_components
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/18247

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@ahcorde ahcorde merged commit fc1afcb into ros2:rolling Feb 19, 2026
3 checks passed
@pum1k
Copy link
Contributor Author

pum1k commented Feb 19, 2026

@ahcorde Could this be backported to Jazzy?

@ahcorde
Copy link
Contributor

ahcorde commented Feb 19, 2026

https://github.com/Mergifyio backport kilted jazzy humble

@mergify
Copy link
Contributor

mergify bot commented Feb 19, 2026

backport kilted jazzy humble

✅ Backports have been created

Details

mergify bot pushed a commit that referenced this pull request Feb 19, 2026
Signed-off-by: pum1k <55055380+pum1k@users.noreply.github.com>
(cherry picked from commit fc1afcb)
mergify bot pushed a commit that referenced this pull request Feb 19, 2026
Signed-off-by: pum1k <55055380+pum1k@users.noreply.github.com>
(cherry picked from commit fc1afcb)
mergify bot pushed a commit that referenced this pull request Feb 19, 2026
Signed-off-by: pum1k <55055380+pum1k@users.noreply.github.com>
(cherry picked from commit fc1afcb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rclcpp_components_register_nodes() fails if not in the project's root CMakeLists.txt

3 participants

Comments