CMake's execute_process
command seems to only let you, well, execute a process - not an arbitrary line you could feed a command shell. The thing is, I want to use pipes, file descriptor redirection, etc. - and that does not seem to be possible. The alternative would be very painful for me (I think)...
What should I do?
PS - CMake 2.8 and 3.x answer(s) are interesting.
execute_process command seems to only let you, well, execute a process - not an arbitrary line you could feed a command shell.
Yes, exactly this is written in documentation for that command:
I want to use pipes
Different
COMMAND
within sameexecute_process
invocation are actually piped:file descriptor redirection, etc. - and that does not seem to be possible.
For complex things just prepare separate shell script and run it using
execute_process
. You can pass variables from CMake to this script using its parameters, or with prelimiaryconfigure_file
.You can execute any shell script, using your shell's support for taking in a script within a string argument.
Example:
will result in
FOO
containingworld
.Of course, you would need to escape quotes and backslashes with care. Also remember that running bash would only work on platforms which have bash - e.g. not Windows.