Nature of the octahedral tilting phase transitions in perovskites: A case study of CaMnO3