How it works

The execute_process command will spawn one or more child processes from within the currently executing CMake process, thus providing a powerful and convenient way of running arbitrary commands when configuring your project. It is possible to execute more than one command within one invocation of execute_process. Notice, however, that the output of each command will be piped into the next. The command accepts a number of arguments:

  • WORKING_DIRECTORY lets you specify in which directory the commands should be executed.
  • RESULT_VARIABLE will contain the result of running the processes. This is either an integer to signal successful execution or a string with the error condition incurred.
  • OUTPUT_VARIABLE and ERROR_VARIABLE will contain ...

Get CMake Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.