From a cis/straight guy's perspective, I used to find myself in this situation a regularly. I've found a good combination of pragmatic coping strategies and reframing the person is helpful. Others have mentioned common coping strategies like distraction and minimizing contact, but I find this alone doesn't help set you up for healthy relationships because it only treats the person you're infatuated with as the "forbidden/unworthy object of desire" rather than their own person. So a lot of the reframing I'd do was geared towards reframing then as anyone else that you're not interested in pursuing, so things like
"I'm not their person and they're not my person",
"they're not into me and that's not hot",
"they're a friend/sibling who has their own life, I'll support them in theirs, but I should focus on mine"
It's also always good to put yourself in their shoes. If you were in a relationship and knew someone who you're not into was infatuated with you, how would you want them to act? I doubt you'd want them to pursue you or conversely treat you like toxic waste just to cope.
It's infatuation, it will pass. Love must be mutual and is built over time.
TL;DR: As a guy, this usually ends up being a lot of "Don't be a creep, just be fucking normal."