BASIS  version 1.2.3 (revision 2104)
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.


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:

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.