A general theory of thermoelastic solids restrained by an internal thermomechanical constraint