CMake: fix dependency problems