On the thermodynamics of cocrystal formation