Refactor the CMake files