cmake: some win32 fixes

These are just the win32 specific commits from #5014 that provide some improvements and fixes for the newly added cmake build system for binary addons.