Shape-morphing finds widespread utility, from the deployment of small stents and large solar sails to actuation and propulsion in soft robotics. Origami structures provide a template for shape-morphing, but rules for designing and folding the structures are challenging to integrate into broad and versatile design tools. Here, we develop a sequential two-stage optimization framework to approximate a general surface by a deployable origami structure. The optimization is performed over the space of all possible rigidly and flat-foldable quadrilateral mesh origami. So, the origami structures produced by our framework come with desirable engineering properties: they can be easily manufactured on a flat reference sheet, deployed to their target state by a controlled folding motion, then to a compact folded state in applications involving storage and portability. The attainable surfaces demonstrated include those with modest but diverse curvatures and unprecedented ones with sharp ridges. The framework provides not only a tool to design various deployable and retractable surfaces in engineering and architecture, but also a route to optimizing other properties and functionality.