scp fails in post build command

I’m running cmake 3.20.2 on Windows 10 and trying to call scp to copy an artefact to a remote machine after a successful build:

    TARGET wdt_interrupt_gnu
    COMMAND ${CMAKE_OBJCOPY} -O verilog $<TARGET_FILE:wdt_interrupt_gnu>  
    COMMAND scp.exe ${CMAKE_CURRENT_BINARY_DIR}/wdt_interrupt_gnu.vlg <user name>@<remote path>

When running make that step fails:

process_begin: CreateProcess(NULL, scp.exe C:/<snip>/build/wdt_interrupt_gnu.vlg <user name>@<remote path>, ...) failed.
make (e=2): The system cannot find the file specified.
make[2]: *** [wdt_interrupt_gnu.axf] Error 2
make[2]: *** Deleting file `wdt_interrupt_gnu.axf'
make[1]: *** [CMakeFiles/wdt_interrupt_gnu.dir/all] Error 2
make: *** [all] Error 2

Any suggestions how to fix this please?

It looks like scp is not available in PATH. Can you use a full path to the binary instead (maybe with find_program)?

@ben.boeckel Thanks, but with path provided by find_program I get a similar error:

process_begin: CreateProcess(NULL, C:/Windows/System32/OpenSSH/scp.exe C:/SVNProj/Elysion/trunk/software/prototypes/wdt_interrupt_gnu/build/wdt_interrupt_gnu.vlg <user name>@<remote path>, ...) failed.

Hmm. I think figuring out what “the file specified” being referred to here is would be the next step. You can use Process Monitor to do this (though it isn’t trivial, there are blogs about how to use it).