Hadithcore
Mishkat al-Masabih, 713

Jundub told of his hearing the Prophet (ﷺ) say, “Those who preceded you used to take the graves of their prophets and righteous men as mosques, but you must not take graves as mosques; I forbid you to do that.” Muslim transmitted it.

وَعَن جُنْدُب قَالَ: سَمِعْتُ النَّبِيَّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ يَقُولُ: «أَلَا وَإِنَّ مَنْ كَانَ قَبْلَكُمْ كَانُوا يَتَّخِذُونَ قُبُورَ أَنْبِيَائِهِمْ وَصَالِحِيهِمْ مَسَاجِدَ أَلَا فَلَا تَتَّخِذُوا الْقُبُورَ مَسَاجِدَ إِنِّي أَنْهَاكُمْ عَنْ ذَلِكَ» . رَوَاهُ مُسلم

References1 variant
In-Book Reference
Book 4, Hadith 143