I am also dealing with this type of problem and have found looking at how the transport_drivers repo is structured quite helpful. the io_context library is shared between the serial_driver and udp_driver and utilizes the ament_auto_add_library macro to auto-generate a shared library.