CMake's command execute_process

Source: Internet
Author: User

Execute_process (COMMAND [args1 ...] [COMMAND [Args2 ...]                [...]]                [Working_directory]                [TIMEOUT]                [Result_variable]                [Output_variable]                [Error_variable]                [Input_file]                [Output_file]                [Error_file]                [Output_quiet]                [Error_quiet]                [Output_strip_trailing_whitespace] [Error_strip_trailing_whitespace]) The Execute Process command can execute system commands and save the output to a CMake variable or file. For example, you want to use GIT commands to read the version number in your code.    Another example is that you want to list the names of some files to use in your code. A simple example will be given for your reference later. Runs the given sequence of one or more commands with the standard output of each process piped to the standard input of th E Next. A single standard error pipe was used for all processes. Runs one or more given sequence of commands, and the standard output of each process flows to (pipe) the normal input of the next process. All processes use a separate standard error pipe.    Options:command A child process COMMAND line. CMake executes the child process using operating system APIs directly. All arguments is passed verbatim to the child process. No Intermediate shell is used, so shell operators such as > be treated as normal arguments. (with the input_*, output_*, and error_* options to redirect stdin, stdout, and stderr.) Command child process command line. CMake executes the child process directly using the APIs of the operating system. All parameters are passed verbatim. No intermediate scripts are used, so script operators like > (output redirection) are treated as normal parameters. (Use Input_, Output_, error_ those options to redirect stdin, stdout, stderr.) Working_directory The named directory is set as the current working directory of the child processes. Work path specified will be set to the current working directory of the child process. TIMEOUT the child processes'll be terminated if they does not finish in the specified number of seconds (fractions is Allowed). The timeout child process will be interrupted if it has not ended within the specified number of seconds (the use of fractions is allowed). Result_variable the VARIABLE is set to contain the result of running the processes. This would be a integer return code from the last child or a string describing an error condition. The result variable variable is set to include the run result of the sub-process 。 The return code will be an integer from the last child process or an error description string. Output_variable, error_variable The VARIABLE named is set with the contents of thePut and standard error pipes, respectively. If the same variable is named for both pipes their outputs will being merged in the order produced. Output variable, the variable named by the error variable is set to the standard The contents of the output and standard error pipes. If the same name is named for 2 pipes, their output will be merged in the order they were produced. Input_file, Output_file, error_file the FILE named would be attached to the standard input of the first process, Standar D 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'll be a used for both. input file, output file, error file name file will separate with the first child process of the standard input, the most The standard output of the latter child process is associated with the standard output of all processes. If the same file name is specified for both output and error, 2 will be associated. Output_quiet, error_quiet the standard output or standard error results'll be quietly ignored. Output ignored, error ignored The result is silently ignored. If more than one output_* or error_* option was given for the same pipe the precedence was not specified. If no output_* or error_* options is given the OUTPUT would be is shared with the corresponding pipes of the CMake process it Self. If multiple error and output options are specified for the same pipe, the priority is unknown. If no output and error options are specified, the output and the CMAKE-Process shared pipelines. The execute_process () command is a newer more powerful version of Exec_program (), but the old command had been kept for CO Mpatibility. Both commands run while CMake are processing the project prior to build system generation. Use Add_custom_target () and Add_custom_command () to create custom commands, the run at Build time.execute_process () command is EX Ec_program () A new, more powerful version, but the old command is still compatible. These two commands run in the CMake process project, before the System Builder is built. Use Add_custom_target () and Add_custom_command () to create custom commands that run at build time. The following example is tested by me, if the specified output_file,output_variable will not be valid.                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 Command execute_process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.