initial checkin, add CMake build, fix compile bugs