cmake的命令execute_process

更新时间:2023-07-20 12:19:49 阅读: 评论:0

cmake的命令execute_process
execute_process(COMMAND <cmd1> []]
[COMMAND <cmd2> [] [...]]
[WORKING_DIRECTORY <directory>]
[TIMEOUT <conds>]
大小成语
单县实验小学[RESULT_VARIABLE <variable>]
推崇备至[OUTPUT_VARIABLE <variable>]
[ERROR_VARIABLE <variable>]
[INPUT_FILE <file>]
[OUTPUT_FILE <file>]
[ERROR_FILE <file>]
党员个人问题清单及整改措施
辩论题
[OUTPUT_QUIET]
[ERROR_QUIET]
[OUTPUT_STRIP_TRAILING_WHITESPACE]
[ERROR_STRIP_TRAILING_WHITESPACE])
执⾏进程
这条命令可以执⾏系统命令,将输出保存到cmake变量或⽂件中。⽐如你想通过git命令读取版本号,在代码中使⽤。⼜⽐如你想列出某些⽂件的名称在代码中使⽤。
后⾯还会给出⼀个简单的例⼦供⼤家参考。
Runs the given quence of one or more commands with the standard output of each process piped to the standard input of the next. A single standard error pipe is ud for all process.
运⾏⼀个或多个给定的命令序列,每⼀个进程的标准输出流向(管道)下⼀个进程的标准输⼊。所有的流程使⽤⼀个单独的标准错误管道。
Options:
带草的字
COMMAND
A child process command line.
CMake executes the child process using operating system APIs directly. All arguments are pasd VERBATIM to the child process. No intermediate shell is ud, so shell operators such as > are treated as normal arguments. (U the INPU 命令
⼦进程命令⾏。CMake使⽤操作系统的APIs直接执⾏⼦进程。所有的参数逐字传递。没有中间脚本被使⽤,所以像>(输出重定向)这样的脚本操作符被当作普通参数处理。(使⽤INPUT_、OUTPUT_、ERROR_那些选项去重定向 stdin、stdout、WORKING_DIRECTORY
The named directory will be t as the current working directory of the child process.
⼯作路径
指定的⽬录将被设置为⼦进程的当前⼯作⽬录。
TIMEOUT
The child process will be terminated if they do not finish in the specified number of conds (fractions are allowed).
超时
⼦进程如果在指定的秒数内未结束将被中断(允许使⽤分数)。
RESULT_VARIABLE
The variable will be t to contain the result of running the process. This will be an integer return code from the last child or a string describing an error condition.
结果变量
变量被设置为包含⼦进程的运⾏结果。返回码将是⼀个来⾃于最后⼀个⼦进程的整数或者⼀个错误描述字符串。
eson陈奕迅OUTPUT_VARIABLE, ERROR_VARIABLE
The variable named will be t with the contents of the standard output and standard error pipes, res
pectively. If the same variable is named for both pipes their output will be merged in the order produced.
输出变量,错误变量
命名的变量将被分别设置为标准输出和标准错误管道的内容。如果为2个管道命名了相同的名字,他们的输出将按照产⽣顺序被合并。
INPUT_FILE, OUTPUT_FILE, ERROR_FILE醋泡黑豆
The file named will be attached to the standard input of the first process, standard output of the last process, or standard error of all process, respectively. If the same file is named for both output and error then it will be ud for both.
输⼊⽂件,输出⽂件,错误⽂件
命名的⽂件将分别与第⼀个⼦进程的标准输⼊,最后⼀个⼦进程的标准输出,所有进程的标准输出相关联。如果为输出和错误指定了相同的⽂件名,2个都将会被关联。
OUTPUT_QUIET, ERROR_QUIET
The standard output or standard error results will be quietly ignored.
输出忽略,错误忽略
标准输出和标准错误的结果将被静默地忽略。
If more than one OUTPUT_* or ERROR_* option is given for the same pipe the precedence is not specified. If no OUTPUT_* or ERROR_* options are given the output will be shared with the corresponding pipes of the CMake process itlf.
如果为同⼀个管道指定了多个错误和输出选项,优先级是未知的。如果未指定输出和错误选项,输出将和cmake进程共享管道。
The execute_process() command is a newer more powerful version of exec_program(), but the old command has been kept for compatibility. Both commands run while CMake is processing the project prior to build system generation. U add_c execute_process() 命令是 exec_program()的新的更强⼤的版本,但是旧命令仍被兼容。这两个命令运⾏在cmake处理项⽬时,构建系统⽣成器之前。使⽤add_custom_target()和add_custom_command()创建在构建时运⾏的⾃定义命令。
下⾯的例⼦经本⼈测试,如果指定了OUTPUT_FILE,OUTPUT_VARIABLE将⽆效。
cmake_minimum_required(VERSION 3.0)
execute_process(COMMAND touch aaa.jpg
COMMAND touch bbb.png
COMMAND ls
COMMAND grep -E "png|jpg"
OUTPUT_FILE pics)

本文发布于:2023-07-20 12:19:49,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1089041.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:输出   错误   标准   进程
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图