cygwin fixes, cmake modified to build out of source

Couple of fixes for cmake to build out of source plus fix for building on Cygwin.