Hosting non-classical states of light in three-dimensional microwave cavities has emerged as a promising paradigm for continuous-variable quantum information processing. Here we experimentally demonstrate high-fidelity generation of a range of Wigner-negative states useful for quantum computation, such as Schrödinger-cat states, binomial states, Gottesman-Kitaev-Preskill (GKP) states, as well as cubic phase states. The latter states have been long sought after in quantum optics and were never achieved experimentally before. To do so, we use a sequence of interleaved selective number-dependent arbitrary phase (SNAP) gates and displacements. We optimize the state preparation in two steps. First we use a gradient-descent algorithm to optimize the parameters of the SNAP and displacement gates. Then we optimize the envelope of the pulses implementing the SNAP gates. Our results show that this way of creating highly non-classical states in a harmonic oscillator is robust to fluctuations of the system parameters such as the qubit frequency and the dispersive shift.