Merge pull request #505 from Alexpux/master

More work on cmake port for mingw.