[CMake] How to write a correct wrapper of MESSAGE()?

Matthew Woehlke matthew.woehlke at kitware.com
Mon Oct 14 13:07:06 EDT 2013


On 2013-10-09 07:44, Johannes Zarl wrote:
> I guess you search for something like this:
>
> function(info)
>      set(msg)
>      foreach(i RANGE ${ARGC})
>          set(msg "${msg}${ARGV${i}}")
>      endforeach()
>      message(STATUS "[info] ${msg}")
> endfunction()
>
> message("Foo:bar;baz space" "FOO")
> info("Foo:bar;baz space" "FOO")
> message(two words)
> info(two words)
>
> ....which yields the following output:
>
> Foo:bar;baz spaceFOO
> -- [info] Foo:bar;baz spaceFOO
> twowords
> -- [info] twowords
>
> The "IN LISTS" signature of foreach seems to do additional list splitting,
> leading to ("foo;bar" "baz") appearing as 3 elements. Accessing the ARGV array
> by the positional indices (e.g. ${ARGV0}) prevents the splitting.

Really? That... is surprising. I thought the whole point of 'IN LISTS' 
was to take a variable that already contains a list and NOT do 
additional splitting (the way 'foreach(NAME ${LIST})' would)...

-- 
Matthew



More information about the CMake mailing list