On 17. Mar, 2010, at 21:46 , Alan W. Irwin wrote:

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

Well, you still could use a cmake script like a normal shell script, passing 
the arguments using -D flags...

I just tried a few things, and it seems that you can use eval to your advantage:

project(test C)
add_custom_command(OUTPUT bla.stderr bla.stdout
  COMMAND eval
    "((echo 'this is stdout'; echo 'this is stderr' >&2) > bla.stdout) 2> 
bla.stderr"
  VERBATIM
  )
add_custom_target(bla ALL DEPENDS bla.stderr bla.stdout VERBATIM)


Tried it with the "Unix Makefiles" and "Xcode" generators, works for both.

Michael

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to