Various required CMake bits and patches to get the code to compile