improve custom command for Visual Studio
add_custom_command()
understands generator expressions. Unfortunately it is not possible to add custom commands for one specific configuration only. This MR fixes this.
The following adds a post build command my_debug_command
to tgt
for the Debug
configuration:
add_custom_command(TARGET tgt POST_BUILD
COMMAND
$<$<CONFIG:Debug>:my_debug_command>
)
For Release
an empty command will be added. In my case there is
""
somewhere written in the post build script. This causes the step to fail, so I had to run empty dummy commands like
${CMAKE_COMMAND} -E touch_no_create <somefile>
This works but clutters the post build script with nonsense content which is in turn hard to debug.
In addition, for every custom command which is added to a target, a new :cmEnd
section is created. This MR removes all but the last :cmEnd
occurences to make reading/debugging generated custom command scripts even easier.