5W-40 M1 should be fine.
If I recall correctly, the M10 (and M30's) from our era had 20W-50 recommended by BMW - but newer oil is a bit better than the old dino oil from back then.
I used 15W-50 M1 in my 2002 for the 30 years I had it. I have used that in my M30 (in the E9) also - but now with the M90 installed... Will need to re-evaluate what I put in.
And... Probably go to the 5W-40 as well for the new motor.
For the 5W-40, I use Mobil 1 Turbo Diesel Truck (or Delvac 1). Both are rated for gas motors as well as diesel. And being for diesel, they have higher values of the additives that are being removed from the 'gas only' API rating oils these days.
I've been using TDT or D1 in my M60/M62 and 997 for... uh.... about 550,000 miles all told now... (250k in E38 #1, 240k in E38 #2 and 70k in the 997 - all of these motors running great BTW). I used this oil in my F250 PSD also