cmake improvements

Don't merge until Travis approves.

Cleaned repeated logic, added a few options.

Tested all added options on Windows -- they work.