It’s been my practice for 20 years to not comment about anyone’s physical appearance or manner of dress unless it violates policy in some way and I am their manager. Not in a work setting, not in a social setting where co-workers are present. It takes virtually zero effort to do this.
When someone makes a comment of this nature towards me, I acknowledge it and move on. I don’t consider it harassment personally, and a lot of times it’s just a nice gesture, but I appreciate how it can be inappropriate and bright lines are easier than grey areas so that’s how it goes.