CMake build system

The CMake build system should now work correctly. I had to change two lines `istream` related line in order to support VS2013, but I believe everything works fine now.