Fix CMakeLists and building with gcc 4.6