1 — The Shāfiʿī school: it counts as a major sin.
The jurist Ibn Ḥajar al-Haytamī states in al-Zawājir 1/120:
“The ninety-third through ninety-eighth major sins are: turning graves into mosques, lighting lamps on them, treating them as idols, circumambulating them, touching them, and praying toward them.”
After citing some of the previously mentioned hadiths and others besides, he adds (p. 111):
“Note: The classification of these six acts as major sins appears in the words of some Shāfiʿī scholars, and it seems they based it on the hadiths I have just quoted. The reason why taking a grave as a mosque falls under this heading is clear: the Prophet cursed those who did that with the graves of their prophets, and he declared that anyone who does the same with the graves of the righteous will be the worst of Allah’s creation on the Day of Resurrection. This serves as a warning to us, as in the report, ‘He warned against what they had done,’ meaning that he warned his community, saying it so that they would not imitate those people and thus be cursed as they were. Accordingly, our scholars have ruled: it is forbidden.