[CMake] Passing a CMake list "as is" to a custom target
Michael Hertling
mhertling at online.de
Wed Jun 22 16:09:02 EDT 2011
On 06/22/2011 09:14 PM, Hauke Heibel wrote:
> 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
You might use -DMY_VARIABLE="${ARGUMENTS}" without VERBATIM, and
SEPARATE_ARGUMENTS(MY_VARIABLE) in Foo.cmake. This doesn't prevent
the list's conversion, but seems a bit smarter than a FOREACH loop.
'hope that helps.
Regards,
Michael
More information about the CMake
mailing list