Generated sources in metadata-dependency

We have a multiplatform-project using kapt to generate sources for annotated classes in commonMain.
The sources are added by a custom SourceSet named “generated” to jvm and js targets. This works well.

We now have to depend on this from another multiplatform project’s commonMain. Unfortunately the classes from the generated SourceSet are only added to jvm and js jars, but not to the metadata that is used resolving the dependencies of commonMain (since we can only depend on generated from the jvmMain and jsMain and not from commonMain (circular dependency)).

How can we add generated classes to the metadata-artifact?