[CMake] COMMAND does not accept standard method of splitting stderr and stdout results

Michael Wild themiwi at gmail.com
Wed Mar 17 15:21:02 EDT 2010


On 17. Mar, 2010, at 18:42 , Alan W. Irwin wrote:

> According to "Unix in a Nutshell", the bourne and korn shells use the
> following method of splitting stderr and stdout into two separate
> files.
> 
> (cmd >f1) 2>f2
> 
> I have checked that the parentheses work for bash, although they are not
> necessary.  Therefore, the above seems to be a good candidate for the best
> way to split stderr and stdout if you want your build system to work for a
> wide variety of bourne (or korn) shell dialects.
> 
> However, CMake COMMAND totally buggers the above construct regardless of
> whether VERBATIM is set and regardless of spacing around the parentheses or
> not.  A number of issues occur, but the constant one for all variants that I
> tried is the opening parentheses are quoted which is then interpreted as a
> separate command (at least by bash).
> 
> Of course, I can always drop the parentheses for my own (bash) needs, and
> then all is well.  But I am concerned that may be a non-standard bashism
> that is being forced on me by CMake that will not work for most/all other
> bourne shell dialects.
> 
> Alan

Thing is, cmake is neither bash nor ksh, else it would be called cash ;-)

To do what you want to do in a platform independent way, is to wrap your command in a .cmake script and in there use EXECUTE_PROCESS, where you have the OUTPUT_VARIABLE, OUTPUT_FILE, ERROR_VARIABLE and ERROR_FILE options.

HTH

Michael


More information about the CMake mailing list