Added CMake project and fixed compiling under MSVC.