In any civil action, in which a waiver of the right of homestead or other exemption is sought to be enforced, the fact of waiver and its extent must be averred in the complaint or petition and by appropriate pleading may be controverted. If such averment is sustained, the fact of waiver and its extent must be declared in the judgment and endorsed on the execution or other process issued thereon. Such waiver shall extend to the costs of the action.