Fix MinGW build and external project build.