It looks like the problem was a combination of various PATH problems described above and the fact that my CMake generator was on Unix Makefiles instead of MinGW (I had been trying both several times but apparently I never tried MinGW at the same time all the path stuff was sorted out).