I have a multi-toolchain development environment (IAR-ARM, MSVC, and Tensilica-Clang) and mapfile are invaluable to embedded development.
In each toolchain file, I’m able to set default linker flags, etc, but in general the argument required for the mapfile flag requires a filename. I can put a fixed filename (like output.map), but that doesn’t work very well.
Because cmake/ninja runs at the root of the build directory that’s where the mapfile ends up. I’d prefer to make it show up next to the output binary with the same name, but .map.
I’ve yet to find a way to add to CMAKE_EXE_LINKER_FLAGS something that takes into account “current output directory” or anything like that.
How do I do this, without wrapping add_exectuable() and adding the toolchain specific flag based on the toolchain in use?