[ros2] components registration from subdirectory CMakeLists file
I have a package that is separated into couple of subdirectories, each has its own CMakeLists.txt file that is included to the main CMakeLists.txt file by using add_subdirectory(). Each of these subdirectories contains the source code files for a different component that I want to use: e.g, I have a detection subdirectory, a tracking subdirectory and so forth. I am trying to register node components from within the subdirectories CMakeLists files by using rclcpp_components_register_nodes() but it seems as if the nodes don't get registered when I try to load them. Furthermore, they are not located at share/ament_index/resource_index/rclcpp_components/ like other components that I use.
If I take the contents of the subdirectories' CMakeLists.txt file to the main CMakeLists.txt and remove the call to add_subdirectory, everything works fine.
Anyone done something similar before?
Thanks in advance for any help.