Cmake build and Fix for Mac

Hi @the-real-blackh,

here's a patch to add a CMake build file for C++, and to fix the build on the Macintosh.

Best Regards
@antmd