add building using cmake
add install option
fix build errors with g++ 4.9.0