美文网首页
Windows 环境下 cmake 的 execute_proc

Windows 环境下 cmake 的 execute_proc

作者: chou_o_ning | 来源:发表于2023-08-22 15:04 被阅读0次

在 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()

相关文章

网友评论

      本文标题:Windows 环境下 cmake 的 execute_proc

      本文链接:https://www.haomeiwen.com/subject/igrumdtx.html