Add compilation flags to g++ in cmake and fix the path problem.