[CMake] Backslashed whitespace in ADD_CUSTOM_COMMAND's ARG expansion
Eric BOIX
eboix at ens-lyon.fr
Thu Oct 13 05:07:38 EDT 2005
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.
More information about the CMake
mailing list