I came across a sentence recently: *Before I turn 40, I want to have written a book.*

Could someone explain to me what does it actually mean? 

I'd rather say: *Before I turn 40, I want to write a book.* but I'm not native speaker. 

I understand the meaning of the perfect infinitive in sentences below:

*If I had known you were coming I would have baked a cake.*

*Someone must have broken the window and climbed in*

but I can't grasp the difference between:

*Before I turn 40, I want to have written a book* vs *Before I turn 40, I want to write a book*

Thanks for any help
Marcel