Added CMake build system.  Few code changes to support g++ compiler.