Rewrite qmake detection to better support Qt5