Windows 环境下 cmake 的 execute_proc

2023-08-22  本文已影响0人  chou_o_ning

在 windows 环境下 cmake 的 add_custom_target() 命令如下:

add_custom_target(
    copyfile ALL copy /y a.c b.c
    DEPENDS xxx
)

但是对于 execute_process() 命令,直接写 windows 下的脚本不执行且没有任何出错打印。需要添加 cmd.exe /C,如下:

execute_process (
    COMMAND cmd.exe /C copy /y a.c b.c
)

如果需要知道脚本执行的结果:

execute_process (
    COMMAND cmd.exe /C copy /y a.c b.c RESULT_VARIABLE result
)
if(${result})
    message(FATAL_ERROR "copy failed")
endif()
上一篇 下一篇

猜你喜欢

热点阅读