Stop cats from spraying without repelling them?

We love cats, our neighbours cats regularly come into our yard for stokes, and a stray cat also comes for food and strokes, he's our favourite. But he keeps spraying in our yard, usually on plants but he just did it all over our lawn mower. When I Google how to stop this, all the suggestions are to repel all cats completely. We obviously don't want to do this. Is there a way to make him stop spraying but still wanna hang out in our yard?