# Using 'install(CODE "execute_process(COMMAND ...' with a shell command

I’ve used the pattern

` install(CODE "execute_process(COMMAND \${CMAKE_COMMAND} -E ...`

successfully many times, but I’m having difficulty where the process I want to run is a Bash shell command rather than a CMAKE -E operation.

Specifically, I want to use ‘chrpath’ to modify some imported ELF files generated by SWIG, changing their RPATHs to RUNPATHs. If I use the most obvious form of the syntax,

``````install(CODE "execute_process(COMMAND chrpath --convert \${CMAKE_INSTALL_FULL_BINDIR}/../lib/python2.7/sil/*.so
COMMAND_ECHO STDOUT)")
``````

…then each block of text between spaces seems to become quoted:

``````'chrpath' '--convert' '<my path>/*.so'
open: No such file or directory
elf_open: Invalid argument
``````

… and the command fails.

If, instead, I use the double-bracket syntax (which I can find in examples in various places but doesn’t seem to be documented:)

``````install(CODE [[execute_process(COMMAND chrpath --convert \${CMAKE_INSTALL_FULL_BINDIR}/../lib/python2.7/sil/*.so
COMMAND_ECHO STDOUT)]])
``````

then it seems to make no difference.

What is the correct syntax to get this to work?

`execute_process` executes the command directly, not through a shell (quoting the docs: “No intermediate shell is used, so shell operators such as `>` are treated as normal arguments.”). Which means `*` is not expanded (as that is done by the shell), so the argument is a literal `*.so`, and I assume there are no such files in the path.

You should either change the command to launch a shell, or do the “expansion” yourself using something like `file(GLOB)`.

Thank you; yes, that does in fact work. I’m afraid I didn’t quite appreciate what the documentation was saying, but using the ‘obvious’ form of the syntax with explicit filenames rather than the wildcard worked successfully. The “\${CMAKE_INSTALL_FULL_BINDIR}” was still expanded properly.