Just because it's there in the contract doesn't mean it's legal.
I'm not sure which European country you are referring to, but as a German I'd look at you funny if you had the audacity to put something like that in an employment contract (but honestly, I very strongly doubt any employer would do so in the first place).
In the UK I've signed a few employment contracts with such clauses, that If I produce something outside of working hours the company still owns it.
I signed the contracts anyway assuming that most likely the company would not be interested in what I created outside working hours (or even know of it) and that they would only get interested if it becamse really successful, in which case I would probably have the means to defend it.