How do I exclude objects from shadow casting across layers?

I'm making a spaceship combat game where the player (and camera) is in the cockpit of their ship. The cockpit needs to be self shadowing, but I don't want other ships that fly by to cast shadows onto it because it makes the shadowmap too large, which creates visual artifacts. However, I also want the external spaceships to self-shadow.

Can I exclude the external ships from casting shadows upon the cockpit while still having them be self shadowed? I have them on separate layers with one directional light for each, but they are getting mixed into each other's shadow map extents. Can this be fixed?

Are you using the culling mask for the light, or is this not doing what you want?