I've owned all of them except the XDm, so it's interesting to me.
Personally, I think the M&P wins, but it doesn't win "out of the box" as they say. To me it definitely needs some love from Apex Tactical to cure the trigger reset.
Sure, you can get trigger jobs on all of them, and if we're just talking about which gun has the best aftermarket trigger it would probably be the Glock, but as a whole I like the M&P better.
These are all my opinions, of course, but the XD feels very blocky and the Glock is not exactly slim either. The XDm appears to add more blockiness and things to snag your shirt on. I imagine that if you got your calipers out there wouldn't be a whole of difference between all four of them, but the M&P is better where it counts
Having said all that, the gun I would recommend to someone wanting their first handgun would be a Glock 17. You can't really go wrong with any of them, but the Glock 17 is the standard by which all these pistols are judged. It's simple to operate and has a great reputation for reliability. Most people will just need to practice and clean it occasionally to have a good carry gun.
If someone is really unnerved by carrying a loaded gun with just a trigger safety, I would recommend the XD, as it adds the grip safety which is mostly unobtrusive. (Though Karl does point out some disadvantages to having one.) I did find that in 1 out of 1000 times (+/-) of practice drawing from concealment and dry firing that I would manage to not engage the grip safety properly. In all those times the fault could be remedied by squeezing harder.
So, I may have drank the M&P coolaid, but I still can see advantages to the other models. (I also want to say that both of my M&P's are well under 6" at 25 yards, but I do know that it's not uncommon to get one that suffers from inconsistent lockup and will show vertical stringing in shot groups. I imagine that Smith and Wesson would fix these for free, but that's just a guess based on how their customer service has treated me when they warrantied my Pro's barrel.)