Well, the good news is that there’s definitely a way to get to this guy to stop flirting with you. The bad news is that it might just be at the expense of your friendship.
I actually answered an almost identical question about a year ago and the only thing that’s changed since then is the amount of faith I have in the flexibility of co-ed relationships. There are always exceptions, but the typical young guy already digging on a girl won’t have the maturity to accept the “consolation prize” (as he’ll see it) of a platonic relationship with her. Whether your dynamic together has been lopsided from the start, or developed into a one-way romance over time, your friend is gonna have a tough time mentally placing you back into that “friendship box” – that is, if he can at all – once he’s already begun viewing you as something more.
As I advised the lady in the post referenced earlier, beyond making your position clear through verbal cues (which it sounds like you’ve already done if he knows that you’re not interested), you’ll have to back away from or break ties with this guy in order to find peace. Even if he is able to temporarily mask his emotions, he won’t be able to actually work past them until he gets enough distance from you.
Fortunately, it should be easier to avoid this guy than the dude who wouldn’t stop harrassing his best friend’s girlfriend — and either way, cutting him off will certainly be less messy. For a smooth transition, be as decisive and clear about your wishes as possible. Your friend might be confused, hormonal, or hopelessly in love, but if you’re not picking up what he’s throwing down, don’t make it your problem when it’s ultimately his!