Gauss-Bonnet dark energy by Lagrange multipliers