We present a broadly applicable, physically motivated, first-principles approach to determining the fundamental gap of finite systems from single-electron orbital energies. The approach is based on using a range-separated hybrid functional within the generalized Kohn-Sham approach to density functional theory. Its key element is the choice of a range-separation parameter such that Koopmans' theorem for both neutral and anion is obeyed as closely as possible. We demonstrate the validity, accuracy, and advantages of this approach on first, second and third row atoms, the oligoacene family of molecules, and a set of hydrogen-passivated silicon nanocrystals. This extends the quantitative usage of density functional theory to an area long believed to be outside its reach.