cmake的命令execute_process

2023-05-16


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)
  

转载于:https://www.cnblogs.com/the-capricornus/p/4759157.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

cmake的命令execute_process 的相关文章

  • 如何在Linux中为特定程序设置进程ID

    我想知道是否有某种方法可以在运行某些应用程序之前强制使用 Linux 的某些特定进程 ID 我需要提前知道进程ID 实际上 有一种方法可以做到这一点 自内核 3 3 设置了 CONFIG CHECKPOINT RESTORE 在大多数发行版
  • 以字符集安全的方式获取 Windows 上的进程列表

    这个帖子 https stackoverflow com questions 54686 how to get a list of current open windows process with java给出了一个在 Windows 下
  • python中通过命令查找进程

    在我的 Python 脚本中 我想检查是否otherscript py目前正在 Linux 系统上运行 这psutil http psutil readthedocs io en latest 图书馆看起来是一个很好的解决方案 import
  • Windows 服务和 Windows 进程有什么区别?

    是什么不同之处窗户之间service和一个窗户process 服务是真正的 Windows 进程 没有区别 服务的唯一特殊之处在于它由操作系统启动并在单独的会话中运行 一种独立的方式 可防止其干扰桌面会话 传统上命名为daemon http
  • 如何以编程方式迭代所有 CMake 目标?

    有没有办法从顶层获取 CMake 项目的所有目标CMakeLists txt 即以编程方式迭代目标 我想要这样做的原因是将一些 XCode 特定设置应用于每个目标 if CMAKE GENERATOR MATCHES Xcode inclu
  • cmake 和视觉工作室

    海湾合作委员会 4 4 2 Visual Studio C 2008 我一直在linux上使用cmake 没有任何问题 现在我已经通过应用程序移植到 Windows 上运行 我使用 cmake G Visual Studio 9 2008
  • 将 cmake 与自定义文件生成器结合使用

    我想使用 CMake 生成混淆的 lua 文件以供交付 在我的一生中 我无法让 add custom command add custom target 为我构建这些文件 我缺少一些东西 ADD CUSTOM TARGET LUABIND
  • CMake:将为 lib 构建的对象文件重用到另一个 lib 目标中

    我正在尝试将我的项目转移到CMake 同时对编译过程进行一些优化 这是交易 我有几个子目录 必须 每个子目录都编译成静态库 这有效 我想将每个子目录中的所有目标文件收集到另一个更大的 完整的静态库中 它看起来像这样 libBig a mad
  • 来自库的 CMake link_directories

    我正在尝试使用 CMake 和 Xcode 从另一个库链接到一个库 这对任何图书馆来说都是一个问题 但为了让事情更容易传达 让我们使用zlib举个例子 这似乎适用于可执行文件 如下所示 LINK DIRECTORIES LIB DIR zl
  • 如何在 Windows 中使用 cmake 更轻松地链接 gtk 库?

    我现在通过手动包含所有必需的路径 gtk包位于D Tools gtk bundle 2 20 0 20100406 win32 include directories D Tools gtk bundle 2 20 0 20100406 w
  • clang-tidy - 忽略第三方标头代码

    我正在为我的项目使用 CMake 并且我想向项目引入 clang tidy 检查 我用于此目的CMAKE CXX CLANG TIDY and clang tidy用于检查设置的文件 我想在 CI 中使用警告作为错误来可靠地检查提交是否引入
  • CreateProcess error=2,系统找不到指定的文件

    我正在用java编写一个程序 它将执行winrar并解压一个jar文件 放在h myjar jar进入文件夹h new 我的java代码是这样的 import java io File import java io IOException
  • cmake MSYS Makefiles 生成器丢失

    我通过 pacman 安装了 cmake 3 2 3 当我尝试从 msys64 shell 中使用它时出现错误 cmake G MSYS Makefiles CMake Error Could not create named genera
  • wasm-ld:错误:初始内存太小,需要 18317952 字节

    我想将 ffmpeg 编译为 wasm 下载 FFMPEG 和 emsdk 源代码后 我使用下面的命令进行构建 emconfigure configure cc emcc enable cross compile target os non
  • 构建涉及 cmake 的项目,如何使其了解库

    当我尝试在 64 位 linux debian 机器上使用 cmake 和 gcc 构建此项目时 我从链接器中收到错误 Linking C executable cpsadamsx home dala lib64 libSimTKcommo
  • CMake Xcode生成器创建了一个无法构建的项目

    我有一个使用 CMake 构建系统的 C 项目 我使用 MacBook Pro 进行开发 因此当我使用终端时 一切都非常顺利 我可以构建我的项目 然而 今天我发现我可以在使用 CMake 生成器创建相应的项目后使用 Xcode gt cma
  • 为什么在谈论线程和进程时,“不要同时格式化软盘”的评论很有趣?

    我正在阅读之间的区别线程和进程 https stackoverflow com questions 200469 what is the difference between a process and a thread并在第二个答案中发现
  • 如何获取进程的错误信息?

    For vsinstr coverage hello exe 我可以使用 C 代码如下 Process p new Process StringBuilder sb new StringBuilder COVERAGE sb Append
  • 是否可以使用 gold 链接器编译和链接 Clang/LLVM?

    我正在为 LLVM Clang 编写自定义通道 重新编译往往需要一段时间并使用大量内存 我听说 gold 链接器 1 比标准 ld 链接器花费更少的时间并且 2 使用更少的内存 有没有办法将标志传递到 LLVM Clang 构建过程并更改为
  • Process.Start 阻塞

    我正在调用 Process Start 但它会阻止当前线程 pInfo new ProcessStartInfo C Windows notepad exe Start process mProcess new Process mProce

随机推荐

  • linux交叉编译c++

    下载g 43 43 交叉编译工具链 sudo apt install g 43 43 arm linux gnueabihf 测试程序 include lt iostream gt using namespace std int main
  • 因子分析factor analysis_spss运用_python建模(推荐AAA)

    sklearn实战 乳腺癌细胞数据挖掘 xff08 博主亲自录制视频 xff09 https study 163 com course introduction htm courseId 61 1005269003 amp utm camp
  • 清除ListBox的列表项(删除所有项目)

    如何清除ListBox的列表项 删除所有项目 xff0c 今天开发程序时 xff0c 有尝试使用此功能 一开始并不是很顺利 循环所有item去做remove时 xff0c 需要执行两次才可以完成清除 debug进行步进跟踪 xff0c 发现
  • SVN查看所有日志提交记录

    1 svn默认显示最近一周的文件提交和修改记录 xff0c 怎么查看更长时间的日志记录呢 xff1f 2 TortoiseSVN 3 点击show all 或者NEXT 100 xff0c 就可显示更长时间的文件提交记录
  • Nearest neighbor graph | 近邻图

    最近在开发一套自己的单细胞分析方法 xff0c 所以copy paste事业有所停顿 实例 xff1a R eNetIt v0 1 1 data ralu site Saturated spatial graph sat graph lt
  • 手把手教你实现一个简单的编译器

    手把手教你实现一个简单的编译器 1 概述 今天我们将学习开发一个编译器 xff0c 但是呢 xff0c 这个编译器并不是说什么都能都编译 xff0c 它只是一个超级小的编译器 xff0c 主要用于说明编译器的一些基本的原理 我们这个编译器可
  • 查看struts版本号

    2019独角兽企业重金招聘Python工程师标准 gt gt gt struts版本信息查看方法 xff1a 查看lib中的 struts2 core jar META INF MANIFEST MF 找到Implementation Ve
  • R语言读取大数据 data.table包 fread函数

    gt setwd 34 D R Tardy 34 gt library data table data table 1 9 6 For help type data table or https github com Rdatatable
  • Android中读取文本文件中内容的方法

    这几天在项目开发中 xff0c 要读取文本文件中内容的 xff0c 因此写了个读取文本文件中内容的方法 xff0c 代码如下 xff1a 读取文本文件中的内容 public static String ReadTxtFile String
  • Error creating bean with name 'objectMapperConfigurer' defined in class path resource

    转载于 https www cnblogs com qianjinyan p 10879065 html
  • C#实现Windows 服务的制作安装和删除[转]

    关于C 实现windows服务的制作与安装还有删除 运行Visual Studio NET xff0c 建立一个C 的Windows服务项目 主程序代码 xff1a 以下是引用片段 xff1a Code using System using
  • 相机与IMU联合标定

    相机与IMU联合标定 1 imu utils 标定IMU的内参1 1 安装环境1 2 录制IMU数据集 2 kalibr 标定工具2 1 安装2 2 校准相机的内外参2 3 校准相机与IMU外参 总结参考资料 1 imu utils标定IM
  • matlab练习程序(寻找凸包,Graham扫描法)

    我不太清楚这个凸包在图像处理中到底会怎样的运用 xff0c 因为这个好像更多的是计算几何或是图形学里面的东西 不过作为一个算法 xff0c 我感觉还是有必要研究一下的 我主要的参考资料是 算法导论 的33 3和这个博客 代码在这里 xff0
  • 1

    stage 1 xff1a 尝试直接使用Adobe acrobat xff0c foxit阅读器 xff0c 以及CAJ等PDF阅读器 xff0c 尝试使用CAJ是因为CAJ有文字识别功能 xff0c 但是对于加密的文档 xff0c 依然是
  • Python自动化备份系统及网站

    随着目前IT迅猛的发展 xff0c 自动化运维对于Linux运维人员也越来越重要 xff0c 传统的运维方式靠大量的人力 xff0c 现在也逐渐转向自动化运维 xff0c 我们常见的跟自动化有关的软件有哪些呢 今天我们来简单列举一下 xff
  • AI 黑箱难题怎么破?基于神经网络模型的算法使机器学习透明化

    编者按 xff1a 人们可以训练人工智能 xff08 AI xff09 和机器人完成任务 xff0c 但整个过程在黑箱中运作 我们并不知道 AI 和机器人是如何决策的 一家名为 OptimizingMind 的初创公司想要解决这个问题 这篇
  • 技术面试介绍

    内容 xff1a 1 技术面试的形式 2 技术面试的大致环节 3 技术面试应具备的素质 4 技术面试的经验建议 参考 xff1a 剑指offer 第二版 第一章 Java程序员面试笔试宝典 第一章 第二章 1 技术面试的形式 技术面试大致上
  • 今天是 Java 诞生日,Java 24 岁了!

    2019独角兽企业重金招聘Python工程师标准 gt gt gt 今天是 Java 诞生日 xff0c Java 今年 24 岁了 xff0c 比栈长还年轻 还有得搞 xff0c 别慌 xff01 作为一名Java语言的学习者 xff0c
  • [原创]求两个经纬度之间的距离

    经常要根据两个经纬度值 求它们之间的距离 delphi实现代码 xff1a 求两个经纬度之间的距离 function Distince const lon1 lat1 lon2 lat2 double double var alpha1 a
  • cmake的命令execute_process

    execute process COMMAND lt cmd1 gt args1 COMMAND lt cmd2 gt args2 WORKING DIRECTORY lt directory gt TIMEOUT lt seconds g