Potential automorphy over CM fields