Cleaned up the CMake scripts a lot. Still more work to be done but that's good enough for now.