BASIS  r3148
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 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:

  • COMMAND
  • WORKING_DIRECTORY
  • TIMEOUT
  • OUTPUT_FILE
  • ERROR_FILE
  • OUTPUT_QUIET
  • ERROR_QUIET
  • OUTPUT_STRIP_TRAILING_WHITESPACE
  • ERROR_STRIP_TRAILING_WHITESPACE

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

Copyright (c) 2011, 2012 University of Pennsylvania. All rights reserved.
See https://www.cbica.upenn.edu/sbia/software/license.html or COPYING file.

Contact: SBIA Group <sbia-software at uphs.upenn.edu>

Definition in file ExecuteProcess.cmake.


Variable Documentation

cmake ARGS

Definition at line 101 of file ExecuteProcess.cmake.

Definition at line 94 of file ExecuteProcess.cmake.

cmake CMD

Definition at line 174 of file ExecuteProcess.cmake.

cmake COMMAND

Definition at line 88 of file ExecuteProcess.cmake.

Definition at line 79 of file ExecuteProcess.cmake.

Definition at line 113 of file ExecuteProcess.cmake.

cmake RETRY

Definition at line 189 of file ExecuteProcess.cmake.

Definition at line 162 of file ExecuteProcess.cmake.

cmake RETRY_DELAY

Definition at line 166 of file ExecuteProcess.cmake.

cmake RETVAL

Definition at line 220 of file ExecuteProcess.cmake.

cmake STDERR

Definition at line 288 of file ExecuteProcess.cmake.

cmake STDOUT

Definition at line 289 of file ExecuteProcess.cmake.

cmake TMP

Definition at line 299 of file ExecuteProcess.cmake.