1863, Amer.Eng., from
cake (n.) +
walk, probably in ref. to the cake given as a prize for the fanciest steps in a procession in a Southern black custom (explained by Richard H. Thornton, 1912, as, "A walking competition among negroes," in which the prize cake goes to "the couple who put on most style"). Its figurative meaning of "something easy" (1863) is recorded before the literal one (1879). This may also be the source of the phrase
to take the cake (1847).
Piece of cake "something easy" is from 1936.