target_capnp_sources creates a TARGET_headers custom target that other targets can depend on to make sure generated headers exist, but it only creates it on the first call for a target. Headers from later calls for the same target, for example optional schemas or schemas added with a different include prefix, are left out, so building TARGET_headers does not generate them.
Bitcoin Core runs into this in bitcoin/bitcoin#10102, which adds wallet.capnp to bitcoin_ipc with a second target_capnp_sources call (it is only built with the wallet enabled). The CI iwyu job only builds the *_headers targets before running IWYU, so wallet.capnp.h and wallet.capnp.proxy.h were never generated and files including them failed to compile, which fails the job since bitcoin/bitcoin#36235.
This PR makes later calls add a helper target for their headers and makes TARGET_headers depend on it, since dependencies cannot be added to an existing custom target.