I'm building an executable using the standard command:
add_executable(MyExe a.c b.c)
I'm adjusting the CMAKE_EXE_LINKER_FLAGS
to emit a map file, and it works.
If I delete the map file, though, performing an incremental build doesn't regenerate the map file. This makes sense, since I haven't expressed to cmake that the map file depends on MyExe. In the above scenario, the MyExe.map isn't even a target, so cmake doesn't even know it exists.
I've tried creating a custom target, but I can't create a custom command that regenerates the map file, since it comes from add_executable()
. I then tried to use add_dependencies()
, but that seems to only influence the build order.
I could explicitly re-run the linker as a custom command that builds a custom target, but that seems wasteful since linking does take a bit of time.
It almost seems like I need some way to tell add_executable that there are more outputs than just the executable image. Is there a way to do this?
If anybody could point me in the right direction, I'd appreciate it! Thanks in advance for reading.