Refactor the CMake file to work with CMake 3.8.2