[CMake] Problem piping 'execute_process' output

Tyler tyler at cryptio.net
Fri Apr 29 10:41:16 EDT 2011


On Fri, Apr 29, 2011 at 2:46 AM, J.S. van Bethlehem
<j.s.van.bethlehem at astro.rug.nl> wrote:
> execute_process(COMMAND ./source OUTPUT_FILE source.out ERROR_FILE
> source.out)
>
> I would expect to see both lines in 'source.out'. But in reality only the
> second line, that went to the error stream is in the outputfile.
> Interestingly, if I change the ordering of the two lines in source.cc, again
> only the second line appears (now the 'cout' line) Only if I send both lines
> to the same stream, either cout or cerr, I get both lines in the outputfile.
>
> Am I trying do something that is not possible (I think not, given that the
> manual explicitly states that OUTPUT_* and ERROR_* may be the same and that
> results will be merged), do I need to add some more syntax, or did I stumble
> across a genuine bug?

If the docs say this should work, then either it's a bug or the docs
are wrong. Your approach seems sound. You might wait for one of the
actual developers to weigh in, but you can probably just add this to
the bug tracker.

You could work around it by using separate files for the separate
streams and then recombining them later. Order might be a problem but
AFAIK you can't rely on the order to be correct because the OS will be
buffering the output anyway (unless you're handling that in some other
way). Maybe you could insert a timestamp at the beginning of each line
to facilitate sorting later? Just some ideas.

tyler


More information about the CMake mailing list