I’m not too familiar with IAR (I have used it just casually)
But my gut’s feeling is that you will have a really hard time having a compiler do that, that is because usually you handle versioning in other ways, mainly with your source code management platform of choice (be it git SCN etc) and handling versions of the program is not the compiler’s job and thus output file names are quite unimportant.
Now the way Iwould do what you ask is with by using a real build system (make, Cmake, etc) with that you can easily decide what the object files are called and where you put them, you can also pass symbols to the compiler from the makefile and that way you could check the version from your program
Now if you really must use a #define you could use a simple regexp grep in the makefile to extract the version string form the files and subsequently use it to name the output files accordingly
You can also most probably do this from the IDE but I find that usually this advanced build system options are really well hidden by many menus and sub menus and generally not that well documented