What does adding a module definition file via target_sources do?

What you might be thinking about is how does a *.def file listed in the sources for a target end up being handled.

Yes that is what I was trying to ask. I tried reading the CMake code but it was unclear to me.

I don’t know if the special handling for MSVC in your example is necessary.

I’m not sure based on my past experience it seems there are minor differences between Ninja / Visual
Studio builds on MSVC: