use cmake; fix mingw build