"Depends" and "yes."
Those are your two answers.
Cost accounting is more art than science and the "proper" method entirely depends upon what question the cost data is intended to answer. (BTW, I'm a former CPA, with a B.S. degree in Accounting & Finance.)
All agree that to compute the cost of a product you need to value the inputs into making that particular product. In other words, the direct cost of making that product, such as the hourly rate of the pastry cook that mixed the batter and baked the cakes.
There's a difference of technique as to whether one would then add in indirect labor and other overhead. Sometimes, one adds a percentage of the overhead (including rent, supervisory salaries, etc.) to each product. With that technique, one should be able to add up the "cost" of all the products and arrive at the total expenses of the enterprise. This makes some overall sense and provides balance and symmetry.
However, it doesn't help you figure out how to increase profits by altering product mix or volume. After all, the overhead doesn't change much as you make more or less food.
The main other way of looking at it, is to compute only the direct cost of making the products. The sales price, less the direct cost, gives you the "contribution margin." In other words, the amount of money that product contributes to the enterprise that is then used first to cover overhead and then, if any is left, to make up the profit. The higher the individual margin and the higher the volume, the more money available to cover overhead and profit.
The second method lends itself to answering "what if" questions.
I hope that the above makes some sense.