By inserting index perturbations at certain positions along a semiconductor Fabry-Perot laser cavity the threshold gain for one or several of the longitudinal cavity modes can be selectively lowered to facilitate, e.g., single-mode or two-color operation. Previous design methods were limited to a fairly small number of perturbations, leading to only weakly perturbed cavities and thus a limited freedom in tailoring the spectral properties of the laser. In our approach we fully account for all multiple-reflection events and use a search space that permits any distribution of the locations and lengths of the perturbations. We are therefore able to design cavities with almost arbitrary spectral properties with very low threshold gain values for, e.g., the lasing modes of a two-color cavity. Constraining the design by reducing the geometrical freedom, which can be used to increase the smallest feature size to simplify fabrication, we seamlessly approach the weakly perturbed regime while maintaining much of the freedom for spectral engineering.