Fix building for Windows: cache the Windows-specific variables

Otherwise, we won't link to winsock or set the subsystem correctly.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>