I have the f10 M5 and the 991 911 Carrera S.
Both are amazing. The Porsche is the better sports car, handles better lighter etc.
The M5 is superior as a tourer sports luxury sedan.
If you want a very sporty experience get the Porsche but if you want more comfort and space get the M5.
Porsche 991 911 Carrera S
BMW F06 M6 Gran Coupe
BMW F15 X5 5.0 Xdrive M Sport.