using cross emulator with custom target and ctest

That shouldn’t be necessary according to the docs for add_custom_target(), which state:

If COMMAND specifies an executable target name (created by the add_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_CROSSCOMPILING variable 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_EMULATOR target property is set). In this case, the contents of CROSSCOMPILING_EMULATOR will 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
)
1 Like