Al-Ilmam bi-Ahadith al-Ahkam 86
وَعَن ابْن عمر أَنه كَانَ يَقُول: إِن نَاسا يَقُولُونَ إِذا قعدت عَلَى حَاجَتك فَلَا تسْتَقْبل الْقبْلَة وَلَا بَيت الْمُقَدّس، قَالَ عبد الله: لقد ارتقيت عَلَى ظهر بَيت لنا فَرَأَيْت رَسُول الله ﷺ عَلَى لبنتين مُسْتَقْبل بَيت الْمُقَدّس لِحَاجَتِهِ. أخرجه مَالك أطول من هَذَا، والْحَدِيث فِي الْجُمْلَة عِنْد الْجَمَاعَة كلهم.
From Ibn ʿUmar, that he used to say: "Some people say: When you sit to relieve yourself, do not face the qiblah or Bayt al-Maqdis." ʿAbdullah said: "I went up onto the roof of a house of ours and saw the Messenger of Allah ﷺ [sitting] on two bricks, facing Bayt al-Maqdis, relieving himself." Malik reported it at greater length than this, and the hadith in general is with the whole group.