I'm a guy and I used to get this all the time when I was a bit younger, not so much now but it still happens once every so often. Both men and women say it. I was once told to cheer up by a guy with one leg, which was mildly amusing I guess considering the circumstances.
A lot of people say that this is a form of objectification or misogyny or whatever, really it isn't. It's much, much simpler than that.
The vast majority of the time, the people who say this to strangers just think that they are being friendly. That's all. There's nothing sinister about it, it doesn't come from any kind of internalised prejudice, it's just people being a bit daft and not realising that what they're doing might be a bit annoying, especially if the person they say it to is actually in a bad mood.
Yeah it's a minor annoyance but at the end of the day it's harmless. It's just a case of people talking before thinking, which you can't stop people from doing. I've heard much worse from strangers than 'cheer up'.