[CMake] Passing a CMake list "as is" to a custom target

Hauke Heibel hauke.heibel at googlemail.com
Wed Jun 22 15:14:59 EDT 2011


Hi,

My CMake version is 2.8.3 and I am trying to run a CMake script as a
custom target via

add_custom_target(RunFooTarget ALL
  COMMAND ${CMAKE_COMMAND}
    -DMY_VARIABLE=${ARGUMENTS}
    -P Foo.cmake
  VERBATIM
)

where ${ARGUMENTS} is a standard CMake list (semi-colon separated).
Unfortunately, this list is always converted into a white-space
separated list for the target.

I tried to put ${ARGUMENTS} in quotes as well as escaped quotes but
the list is always converted.

My workaround is a foreach loop in which I am concatenating the
individual list elements via "*" and within Foo.cmake, I am reverting
this change through

string(REGEX REPLACE "\*" ";" MY_VARIABLE ${MY_VARIABLE})

in order to get back to my actual list - but that seems hackish.

Any ideas how to prevent the conversion I mentioned above?

Regards,
Hauke


More information about the CMake mailing list