What ROM did you flash? Any custom ROM should have be rooted already (have SU or SuperSU). Even if it didn't, if you used TWRP to flash, it would have asked to root it for you (not sure about CWM).
Also, just a constructive criticism: try a more descriptive thread title next time. As a Q&A and Help forum, it can be said that practically every person making a thread here wants help with their M8. Having a more descriptive title not only results in a better organized and easy to search forum; but also might attract help faster. Try a more specific description like "Flashed custom ROM, now its asking for SU"