That shouldn’t be necessary according to the docs for add_custom_target(), which state:
If
COMMANDspecifies an executable target name (created by theadd_executable()command), it will automatically be replaced by the location of the executable created at build time if either of the following is true:
- The target is not being cross-compiled (i.e. the
CMAKE_CROSSCOMPILINGvariable is not set to true).- New in version 3.6: The target is being cross-compiled and an emulator is provided (i.e. its
CROSSCOMPILING_EMULATORtarget property is set). In this case, the contents ofCROSSCOMPILING_EMULATORwill be prepended to the command before the location of the target executable.
In other words, I would expect the following to automatically prepend the emulator if one is set on the myexe target:
add_custom_target(data.zip ALL
COMMAND myexe arg1 argN
)