@@ -139,21 +139,49 @@ macro(rosidl_generate_interfaces target)
139139 # afterwards all remaining interface files are .idl files
140140 list (APPEND _idl_tuples ${_idl_adapter_tuples} )
141141
142- # to generate action interfaces, we need to depend on "action_msgs"
142+ # Check for any action or service interfaces
143+ # Which have implicit dependencies that need to be found
143144 foreach (_tuple ${_interface_tuples} )
145+ # We use the parent directory name to identify if the interface is an action or service
144146 string (REGEX REPLACE ".*:([^:]*)$" "\\ 1" _tuple_file "${_tuple} " )
145147 get_filename_component (_parent_dir "${_tuple_file} " DIRECTORY )
148+ get_filename_component (_parent_dir ${_parent_dir} NAME )
149+
146150 if ("${_parent_dir} " STREQUAL "action" )
151+ # Actions depend on the packages service_msgs and action_msgs
152+ find_package (service_msgs QUIET )
153+ if (NOT ${service_msgs_FOUND} )
154+ message (FATAL_ERROR
155+ "Unable to generate action interface for '${_tuple_file} '. "
156+ "In order to generate action interfaces you must add a depend tag "
157+ "for 'service_msgs' in your package.xml." )
158+ endif ()
159+ ament_export_dependencies(service_msgs)
160+ list_append_unique(_ARG_DEPENDENCIES "service_msgs" )
147161 find_package (action_msgs QUIET )
148162 if (NOT ${action_msgs_FOUND} )
149163 message (FATAL_ERROR
150164 "Unable to generate action interface for '${_tuple_file} '. "
151165 "In order to generate action interfaces you must add a depend tag "
152166 "for 'action_msgs' in your package.xml." )
153167 endif ()
154- list_append_unique(_ARG_DEPENDENCIES "action_msgs" )
155168 ament_export_dependencies(action_msgs)
169+ list_append_unique(_ARG_DEPENDENCIES "action_msgs" )
170+
171+ # It is safe to break out of the loop since services only depend on service_msgs
172+ # Which has already been found above
156173 break ()
174+ elseif ("${_parent_dir} " STREQUAL "srv" )
175+ # Services depend on service_msgs
176+ find_package (service_msgs QUIET )
177+ if (NOT ${service_msgs_FOUND} )
178+ message (FATAL_ERROR
179+ "Unable to generate service interface for '${_tuple_file} '. "
180+ "In order to generate service interfaces you must add a depend tag "
181+ "for 'service_msgs' in your package.xml." )
182+ endif ()
183+ ament_export_dependencies(service_msgs)
184+ list_append_unique(_ARG_DEPENDENCIES "service_msgs" )
157185 endif ()
158186 endforeach ()
159187
0 commit comments