My thoughts on both...
Exterior - Porsche looks better and has a cleaner look that just looks more luxurious. X5 is more aggressive however there are some questionable choices, but still not bad, just not E70 or E53 level good.
Interior - BMW is more ergonomic, better looking and in some areas has nicer materials. iDrive is also better than PCM, but most use Apple Carplay so it doesn't really make too much of a difference. Porsche build quality is better, but X5 is also solid. Also, X5 has physical controls, Porsche has touch buttons
Driving Dynamics - Can't speak on this topic as I haven't driven either, however I would put my money on the Porsche having better driving dynamics, handling, steering etc. (based on my experience of the Cayenne Turbo) and in the Porsche world, most of the time the GTS drives better than the Turbo so it should be very impressive for an SUV, as the Turbo is already very good. Sadly the Cayenne uses a ZF-Auto and not a PDK, good transmission but PDK is still better. I'd also put my money on the Cayenne being much more comfortable, Porsche's Air-Suspension and ride and handling balance is just top notch, the X3M and X5M have been criticized for a harsh ride, but as always YMMV (again haven't tested X5M but I do agree for the X3M).
Price - BMW of course, Porsche Tax is a thing, but at least GTS comes with a lot of standard equipment (compared to S/Turbo). Porsche will hold value better, but not as well as a Macan or Porsche sports car.
Verdict - E63S Wagon
Seriously though, I would take an E63S Wagon over both. Sedan like handling with SUV practicality, an AMG V8 and a gorgeous interior.
I would also check out the new GLE 63S, I honestly think it looks better than both the Cayenne and X5 and it has the best engine of the three (in my opinion).