[CMake] Does the echo command use the system shell?

Andreas Pakulat apaku at gmx.de
Thu Jul 29 02:53:18 EDT 2010

On 28.07.10 19:19:08, Óscar Fuentes wrote:
> For creating a file at build time with a content like this:
> #define foo "bar"
> I use this on Linux:
> add_custom_command(OUTPUT buildobj.h
>   COMMAND ${CMAKE_COMMAND} -E echo "\\#define foo \\\"bar\\\""
>   > buildobj.h
>   )
> but that doesn't work on Windows, because it outpus:
> \#define foo "bar"
> Removing the backslashes before `#' fixes the problem on Windows, but
> then breaks the Linux build.
> This looks as if `echo' was using the system shell for doing the job,
> because the escapes works differently on each system.

Its not, see cmake.cxx line 1064, it simply prints out the string to

So possibly the error is in add_custom_command, i.e. that one might
require the platform-specific quoting.


You display the wonderful traits of charm and courtesy.

More information about the CMake mailing list