From Sahih Bukhari (Hadith 145):
Narrated `Abdullah bin `Umar:People say, "Whenever you sit for answering the call of nature, you should not face the Qibla or Baitul-Maqdis (Jerusalem)." I told them, "Once I went up the roof of our house and I saw Allah's Apostle answering the call of nature while sitting on two bricks facing Baitul-Maqdis (Jerusalem) (but there was a screen covering him. ' (Fath-al-Bari, Page 258, Vol)
Reference: Bukhari 145