Cakey foundation usually comes from too much product, dry skin underneath, or layering formulas that do not work together.
Use less product than you think, apply it with a dense, soft brush, and buff it in until it melts into the skin. If you need more coverage, add it only where needed.