Fixing the CMake dependency structure. A lot of things are checked optionally now