First option is correct - which keeps the front to rear tyre ratio the same despite the wider rear tyre.
If you did the 2nd option, you'd end up with a rear tyre profile that was about 1cm taller than the front:
225/45r18 = 660mm diameter
255/40r18 = 661mm diameter
255/45r18 = 687mm diameter
Another option is a:
265/40r18 = 669mm diameter
...which is what I had fitted as the 255/40 was not available originally, and I just stuck with it - but you may get a slight rubbing on hard compressions (I only get it in 2 places on the 'Ring, but that's with aftermarket suspension on hard settings).
But when I bought new tyres in April I went with your 2nd option for a bit more sidewall and haven't had any issues - plus they fill the wheelarches a bit more!