[CMake] EXEC_PROGRAM vs.. EXECUTE_PROCESS problem
Brad King
brad.king at kitware.com
Wed Sep 13 18:05:42 EDT 2006
Alexander Neundorf wrote:
> EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e 'puts Config::CONFIG["libdir"]'
> OUTPUT_VARIABLE RUBY_POSSIBLE_LIB_PATH)
EXECUTE_PROCESS does not use a shell like EXEC_PROGRAM so it directly
converts CMake arguments into command line arguments. The above gives
ruby the command line
[ruby]
[-r]
[rbconfig]
[-e]
['puts]
[Config::CONFIG["libdir"]']
because '' is not a string delimeter for the CMake language. Ruby
complains about the unterminated string because it is getting the script
"'puts". Convert the call to pass a CMake argument with the full script:
EXECUTE_PROCESS(
COMMAND ${RUBY_EXECUTABLE} -r rbconfig
-e "puts Config::CONFIG['libdir']"
OUTPUT_VARIABLE RUBY_POSSIBLE_LIB_PATH
)
> EXEC_PROGRAM(${RUBY_EXECUTABLE} ARGS -r rbconfig -e 'puts
Config::CONFIG[\"archdir\"]'
> OUTPUT_VARIABLE RUBY_ARCH_DIR)
This version works because all the arguments are appended together
separated by whitespace and then passed to a shell. The '' delimeters
work in that shell. This will probably not work on Windows though.
-Brad
More information about the CMake
mailing list