cmake的命令execute_process
execute_process(COMMAND <cmd1> [args1...]]
[COMMAND <cmd2> [args2...] [...]]
[WORKING_DIRECTORY <directory>]
[TIMEOUT <seconds>]
[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 sequence 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 used for all processes.
运行一个或多个给定的命令序列,每一个进程的标准输出流向(管道)下一个进程的标准输入。所有的流程使用一个单独的标准错误管道。 Options: COMMAND A child process command line. CMake executes the child process using operating system APIs directly. All arguments are passed VERBATIM to the child process. No intermediate shell is used, so shell operators such as > are treated as normal arguments. (Use the INPUT_*, OUTPUT_*, and ERROR_* options to redirect stdin, stdout, and stderr.) 命令
子进程命令行。CMake使用操作系统的APIs直接执行子进程。所有的参数逐字传递。没有中间脚本被使用,所以像>(输出重定向)这样的脚本操作符被当作普通参数处理。(使用INPUT_、OUTPUT_、ERROR_那些选项去重定向 stdin、stdout、stderr。) WORKING_DIRECTORY
The named directory will be set as the current working directory of the child processes. 工作路径
指定的目录将被设置为子进程的当前工作目录。 TIMEOUT
The child processes will be terminated if they do not finish in the specified number of seconds (fractions are allowed). 超时
子进程如果在指定的秒数内未结束将被中断(允许使用分数)。 RESULT_VARIABLE
The variable will be set to contain the result of running the processes. This will be an integer return code from the last child or a string describing an error condition. 结果变量
变量被设置为包含子进程的运行结果。返回码将是一个来自于最后一个子进程的整数或者一个错误描述字符串。 OUTPUT_VARIABLE, ERROR_VARIABLE
The variable named will be set with the contents of the standard output and standard error pipes, respectively. 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 processes, respectively. If the same file is named for both output and error then it will be used 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 itself. 如果为同一个管道指定了多个错误和输出选项,优先级是未知的。如果未指定输出和错误选项,输出将和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. Use add_custom_target() and add_custom_command() to create custom commands that run at build time. 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)
cmake的命令execute_process的更多相关文章
- CMake学习笔记四-CMake常用命令
CMake常用命令 PROJECT PROJECT(projectname [CXX] [C] [Java]) 指定工程名称,并可指定工程支持的语言.支持语言列表可忽略,默认支持所有语言 SET ...
- cmake find_package 命令
1. find_package(<Name>)命令首先会在模块路径中寻找 Find<name>.cmake,这是查找库的一个典型方式. 具体查找路径依次为CMake: 变量$ ...
- cmake常用命令总结
最近研究了下cmake,总结了一些常用命令,方便以后快速查找. project(projectname [CXX] [C] [Java]): 设置工程名. set(VAR [VALUE] [CACHE ...
- CMake 常用命令
cmake是现在主流的用于多平台C++构建系统,本文用来记录cmake的一些常用命令的索引,加上一些自己理解,理解有误的话,欢迎大家指出. 常用路径 CMAKE_SOURCE_DIR: 顶级cmake ...
- 通过android studio的gradle强制cmake输出命令详情
https://stackoverflow.com/questions/43439549/force-cmake-in-verbose-mode-via-gradle-and-the-android- ...
- CMake INSTALL 命令设置exe dll lib的安装位置
install(TARGETS ${OUT_NAME} RUNTIME DESTINATION ${CMAKE_BINARY_DIR}/bin LIBRARY DESTINATION ${CMAKE_ ...
- cmake命令收集
cmake中一些预定义变量 PROJECT_SOURCE_DIR 工程的根目录 PROJECT_BINARY_DIR 运行cmake命令的目录,通常是${PROJECT_SOURCE_DIR}/bui ...
- ‘cmake' 不是内部或外部命令 也不是可运行的程序 或批处理文
在 Win7下的命令行模式下,输入cmake相关命令,出现如下错误: ’cmake' 不是内部或外部命令 也不是可运行的程序 或批处理文件 解决方法: 在环境变量中添加cmake的文件路径. 计算机( ...
- cmake命令行生成32位和64位项目
概述 本文演示环境: win10 + VS2017 1.指定变量值 咱们常用命令[cmake ..]在build目录下配置生成项目和解决方案. 其实,这个命令还有其他用法. 指定CMakeLists. ...
随机推荐
- kafka 集群部署 多机多broker模式
kafka 集群部署 多机多broker模式 环境IP : 172.16.1.35 zookeeper kafka 172.16.1.36 zookeeper kafka 172.16 ...
- FZU 2112 Tickets
这个问题可以转变一下,先要知道有几个连通块,连通块之间肯定需要添加一条边, 还需要知道每个连通块内部需要添加几条边,这个问题等价于求一张图至少需要几笔画成,这个问题的答案是度为奇数的点的个数/2 #i ...
- cf Round 594
A.Warrior and Archer(思维) 战士一定会ban掉当前边缘的位置.而战士和射手就会选择剩下的最远的两点.我们让剩下的最远的两点最近就达到了均衡.于是我们枚举战士ban掉的边缘,ban ...
- css清除浮动float的三种方法总结
原文地址: http://my.oschina.net/leipeng/blog/221125 张大神的解析: http://www.zhangxinxu.com/wordpress/2010/01/ ...
- stm32 DMA数据搬运 [操作寄存器+库函数](转)
源:stm32 DMA数据搬运 [操作寄存器+库函数] DMA(Direct Memory Access)常译为“存储器直接存取”.早在Intel的8086平台上就有了DMA应用了. ...
- IOS9中联系人对象的使用及增删改查操作的函数封装
之前克服重重困难把IOS9中新的类联系人搞明白了,现在把增删改查封装成了函数,如下: // // ViewController.m // IOS9中联系人CNContact的使用 // // Crea ...
- Nodejs之package.json介绍说明
规范的package.json及package.json中各属性的作用. "name":包名. "description":包简介. "author& ...
- Twisted源码分析系列01-reactor
转载自:http://www.jianshu.com/p/26ae331b09b0 简介 Twisted是用Python实现的事件驱动的网络框架. 如果想看教程的话,我觉得写得最好的就是Twisted ...
- PHP快速按行读取CSV大文件的封装类分享(也适用于其它超大文本文件)
CSV大文件的读取已经在前面讲述过了(PHP按行读取.处理较大CSV文件的代码实例),但是如何快速完整的操作大文件仍然还存在一些问题. 1.如何快速获取CSV大文件的总行数? 办法一:直接获取文件内容 ...
- linux vi 操作
1.撤消修改或删除操作: 按ESC键返回Command(命令)模式,然后按u键来撤消删除以前的删除或修改:如果您想撤消多个以前的修改或删除操作,请按多按几次u.这和Word的撤消操作没有太大的区别: ...