fixed CMakeLists.txt and some compilation errors