Detect targets cyclic dependence again.

Also fixes the wrong error when there are no default targets.