Error parsing arguments for `execute_process cmake -E env`
> cmake --version
cmake version 3.10.2
OS Windows 10
Following script seems correct:
execute_process(
COMMAND "C:/Program Files (x86)/CMake/bin/cmake.exe"
-E env SOME_VAR="C:/Program Files (x86)"
echo working
OUTPUT_VARIABLE output ERROR_VARIABLE error
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE
)
message(STATUS "output: '${output}' error: '${error}'")
But the CMake reports a warning:
> cmake -P script.cmake
CMake Warning (dev) at script.cmake:4:
Syntax Warning in cmake code at column 18
Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.
-- output: '' error: 'Access is denied'
While in fact it doesn't execute it properly at all.
According to the error message it fails to parse the following part:
-E env SOME_VAR="C:/Program Files (x86)"
^
In fact it parses this completely wrong. The warning disappears when I remove the (x86)
part from the path:
execute_process(
COMMAND "C:/Program Files (x86)/CMake/bin/cmake.exe"
-E env SOME_VAR="C:/Program Files"
echo working
OUTPUT_VARIABLE output ERROR_VARIABLE error
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE
)
message(STATUS "output: '${output}' error: '${error}'")
> cmake -P script.cmake
-- output: 'working' error: ''
Documentation for execute_process
says nothing about escaping arguments/inserting quotes on any stage.
The issues are:
- The error is not reported properly.
- Either documentation incomplete or implementation is not covering the possible use cases.