[CMake] Backslashed whitespace in ADD_CUSTOM_COMMAND's ARG expansion

Mathieu Malaterre mathieu.malaterre at kitware.com
Thu Oct 13 11:15:56 EDT 2005


Eric,

	I believe you are looking for:

$ cmake --help SEPARATE_ARGUMENTS 
                                           SEPARATE_ARGUMENTS
        Split space separated arguments into a semi-colon separated list.

          SEPARATE_ARGUMENTS(VARIABLE)

        Convert the value of VARIABLE to a semi-colon separated list.  All
        spaces are replaced with ';'.  This helps with generating command
        lines.

You need to call it before the ADD_CUSTOM_COMMAND.

HTH,
Mathieu
Ps: By `idl' do you mean RSI scripting language ?


Eric BOIX wrote:
>    Dear CMake users,
> 
> I can't seem to be able to use variable expansion within an ADD_CUSTOM_COMMAND.
> [I'm using cmake version 2.1.0 on linux].
> 
> Here is a small example that shows the encountered difficulty. Assume I define
> the following ADD_CUSTOM_COMMAND:
> 
>     ADD_CUSTOM_COMMAND(
>        OUTPUT    ${CMAKE_CURRENT_BINARY_DIR}/try.cc
>        COMMAND   ${OMNIORB4_IDL_COMPILER}
>        ARGS      -bcxx -Wba -Wbtp
>                  ${CMAKE_CURRENT_SOURCE_DIR}/try.idl
>        DEPENDS   ${CMAKE_CURRENT_SOURCE_DIR}/try.idl
>        COMMENT   "idl generated code"
>      )
> 
> Then when executing the make (yes, my platform is Un*x) the expected command
> gets properly expanded and invoked i.e. I get
>      omniidl -bcxx -Wba -Wbtp [some_path]/try.idl
> where the flags of the ARGS argument (-bcxx -Wba -Wbtp) are ok.
> 
> NOW, I wish to use a variable to store the flags "-bcxx -Wba -Wbtp"
> (because my set of flags is context dependant and I need to define them
>  though a bunch of test). Hence I wrote something like:
> 
>  SET( IDL_FLAGS "-bcxx -Wba -Wbtp")
> 
>  ADD_CUSTOM_COMMAND(
>     OUTPUT    ${CMAKE_CURRENT_BINARY_DIR}/try.cc
>     COMMAND   ${OMNIORB4_IDL_COMPILER}
>     ARGS      ${IDL_FLAGS}                              <---- ONLY CHANGE
>               ${CMAKE_CURRENT_SOURCE_DIR}/try.idl
>     DEPENDS   ${CMAKE_CURRENT_SOURCE_DIR}/try.idl
>     COMMENT   "idl generated code"
>   )
> 
> Alas when executing the make, the following command is now called
>    omniidl -bcxx\ -Wba\ -Wbtp [some_path]/try.idl
> i.e. the white-spaces of the IDL_FLAGS variable get BACKSLAHED when the
> variable expansion is made (which of course confuses the COMMAND...).
> 
> I also tried various combinations of double quotes [and event backslashed
> double quotes in deep despair after doing my googling homework with
> keywords like white-space, whitespace, backslash ADD_CUSTOM_COMMAND,
> ARGS...and going for bug browsing on cmake's bug tracking site], like
>      ARGS      "${IDL_FLAGS}"
> but without success.
> 
>         Any clue about what I'm doing wrong ?
>         Thanks,
>         Eric Boix.
> 
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
> 



More information about the CMake mailing list