Variables
ExecuteProcess.cmake File Reference

Execute process using CMake script mode. More...

#include "${ARGS_FILE}"
+ Include dependency graph for ExecuteProcess.cmake:

Go to the source code of this file.

Variables

cmake cmake ARGS
 
cmake ARGS_SEPARATOR
 
cmake CMD
 
cmake COMMAND
 
cmake CONFIGURED_COMMAND
 
cmake EXECUTE_PROCESS_ARGS
 
cmake RETRY
 
cmake RETRY_ATTEMPTS
 
cmake RETRY_DELAY
 
cmake RETVAL
 
cmake STDERR
 
cmake STDOUT
 
cmake TMP
 

Detailed Description

Execute process using CMake script mode.

This CMake script can be used as argument for the -P option of cmake, when another command shall be executed by CMake, for example, as custom build command. The advantage of using this script is that all options of the CMake command execute_process() can be used, i.e., a timeout can be specified.

The arguments of the execute_process() command have to be specified via the -D option on the command line of cmake before the -P <this script> option is given. The name of the CMake variables must be equal the name of the arguments to the execute_process() command.

Arguments of execute_process() which are considered:

Additionally, matching expressions (separated by ';') to identify error messages in the output streams stdout and stderr can be specified by the input argument ERROR_EXPRESSION. When the output of the executed command matches one of the error expressions, a fatal error message is displayed causing CMake to return the exit code 1.

Setting VERBOSE to true enables verbose output messages.

When the input argument LOG_ARGS evaluates to true, the values of COMMAND, WORKING_DIRECTORY, and TIMEOUT are added to the top of the output files specified by OUTPUT_FILE and ERROR_FILE.

The arguments ARGS and ARGS_FILE can be used to specify (additional) command arguments. The content of the text file ARGS_FILE is read when it this file exists. Separate lines of this file are considered single arguments. The arguments specified by ARGS and ARGS_FILE are concatenated where the arguments given by ARGS follow after the ones read from the ARGS_FILE. All occurences of the string 'ARGS' in the COMMAND are replaced by these arguments. If no such string is present, the arguments are simply passed to the execute_process() command as its ARGS argument. The argument ARGS_SEPARATOR specifies the separator used to separate the arguments given by ARGS and ARGS_FILE when the 'ARGS' string in COMMAND is replaced. By default, it is set to ';'.

Example:

cmake -DCOMMAND='ls;-l' -DWORKING_DIRECTORY='/' -DTIMEOUT=60
-P ExecuteProcess.cmake

The output of the executed process can further be searched for error expressions specified by the ERROR_EXPRESSION variable. If the process output matches this expression, a fatal CMake error is raised.

Certain errors may be temporary such as in particular a license checkout error of the MATLAB Compiler. Such errors can be filtered out using the RETRY_EXPRESSION variable. If such error is detected, this script sleeps for RETRY_DELAY seconds and then executes the process again. This is done at maximum RETRY_ATTEMPTS times. If the retry attempts are exceeded, a fatal CMake error is raised instead.

See also
http://www.cmake.org/cmake/help/cmake2.6docs.html#command:execute_process

Definition in file ExecuteProcess.cmake.

Variable Documentation

§ ARGS

cmake ARGS

Definition at line 111 of file ExecuteProcess.cmake.

§ ARGS_SEPARATOR

cmake ARGS_SEPARATOR

Definition at line 104 of file ExecuteProcess.cmake.

§ CMD

cmake CMD

Definition at line 184 of file ExecuteProcess.cmake.

§ COMMAND

cmake COMMAND

Definition at line 98 of file ExecuteProcess.cmake.

§ CONFIGURED_COMMAND

cmake CONFIGURED_COMMAND

Definition at line 94 of file ExecuteProcess.cmake.

§ EXECUTE_PROCESS_ARGS

cmake EXECUTE_PROCESS_ARGS

Definition at line 123 of file ExecuteProcess.cmake.

§ RETRY

cmake RETRY

Definition at line 199 of file ExecuteProcess.cmake.

§ RETRY_ATTEMPTS

cmake RETRY_ATTEMPTS

Definition at line 172 of file ExecuteProcess.cmake.

§ RETRY_DELAY

cmake RETRY_DELAY

Definition at line 176 of file ExecuteProcess.cmake.

§ RETVAL

cmake RETVAL

Definition at line 230 of file ExecuteProcess.cmake.

§ STDERR

cmake STDERR

Definition at line 298 of file ExecuteProcess.cmake.

§ STDOUT

cmake STDOUT

Definition at line 299 of file ExecuteProcess.cmake.

§ TMP

cmake TMP

Definition at line 309 of file ExecuteProcess.cmake.