0

I am messing around with build time source file generator, and I came across a strange behavior. If I have the following:

ADD_CUSTOM_COMMAND(
    OUTPUT
        ${GENERATED_FILE}
    COMMAND
        echo "// generated file" > ${GENERATED_FILE}
        echo "debugging echo"
    DEPENDS
        my_object_library
    VERBATIM
) 

The generated file ends up with

// generated file echo debugging echo

Anyone know why?

jws
  • 2,171
  • 19
  • 30
  • I think you have to separate the `echo` commands with another `COMMAND` directive. – Kevin Jun 28 '19 at 15:33
  • Agreed but I'd like to understand how this concatenation works. – jws Jun 28 '19 at 15:41
  • On what OS are you seeing this behavior? Windows? Linux? – Kevin Jun 28 '19 at 15:51
  • Linux (Ubuntu 18.04) – jws Jun 28 '19 at 16:24
  • 1
    "I'd like to understand how this concatenation works." - CMake simply passes every `COMMAND` argument to the shell. You may run in the command line `echo "// generated file" > echo "debugging echo"` and you will observe the same result. – Tsyvarev Jun 29 '19 at 17:37

0 Answers0