Skip to content

Fix component registering in subdirectories#3064

Open
pum1k wants to merge 2 commits intoros2:rollingfrom
pum1k:fix/component-in-subdirectory
Open

Fix component registering in subdirectories#3064
pum1k wants to merge 2 commits intoros2:rollingfrom
pum1k:fix/component-in-subdirectory

Conversation

@pum1k
Copy link

@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
Author

pum1k commented Feb 16, 2026

@fujitatomoya Is this what you meant?

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

2 participants