Create target that only runs other target

Just noticed the typo. I’ll try to fix it if I can. But here is an example of what I was trying to convey.

add_custom_target(${targetName}_run 
  COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR } --target ${targetName}_clean
  COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR } --target ${targetName}
  COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR } --target ${targetName}_upload
  )

add_custom_target(${targetName}_run_size 
  COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR } --target ${targetName}_run
  COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR } --target ${targetName}_size
  )

Then you don’t need additional add_dependencies in the function add_avr_executable. You just issue the targets to be executed: clean elf and hex, build elf and hex, and upload. Then you can reuse the commands in new commands. For example ${targetName}_run_size. Or you can issue it from the command line using the --build CMake option or from the build tool like make.