You need to tell CMake which package requires which targets (i.e. generated files, like the message headers or a library) are requires by your target (i.e. executable/library). Do this using the add_dependencies call. This is also described on the catkin documentation on building messages