  We consider shape optimization problems for general integral functionals of
the calculus of variations that may contain a boundary term. In particular,
this class includes optimization problems governed by elliptic equations with a
Robin condition on the free boundary. We show the existence of an optimal
domain under rather general assumptions and we study the cases when the optimal
domains are open sets and have a finite perimeter.
