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

Alan W. Irwin irwin at beluga.phys.uvic.ca
Wed Mar 17 16:46:55 EDT 2010


On 2010-03-17 20:21+0100 Michael Wild wrote:

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

True, but COMMAND does execute a command on the command line, and on the
Unix side of things that must involve the shell.  To confirm that, note that
the Makefiles generated by CMake have the following two lines (at least on
Linux.  I am sure other Unices have something similar to refer to the
Bourne-compatible family of shells)

# The shell in which to execute make rules.
SHELL = /bin/sh

So if CMake screws up standard sh syntax (and I am pretty sure that "Unix in
a nutshell" does emphasize the lowest-common-denominator, bog-standard sh
syntax), then CMake is crippled more than it needs to be.

>
> 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.
>

That's a good idea for a single instance, but that might get a little
complicated if you have hundreds of these. Dave's idea of a single shell
script to work around this issue is pretty simple and should work for all my
instances so that is what I will use.

Despite the availability of workarounds, I still think a useful goal is for
CMake not to mess up bog-standard sh syntax (such as the syntax covered in
"Unix in a nutshell") so that the necessity of workarounds is considerably
reduced.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list