how are igneous rocks formed?

A. compaction and cementation of sediments
B. cooling and solidification of magma
C. weathering of rocks
D. application of pressure and heat to sedimentary rocks