[CMake] New type of cache variable: lists

Robert Dailey rcdailey at gmail.com
Fri Dec 9 14:59:26 EST 2011


BTW thank you for the choice() function. I have looked it over and it looks
perfect. I'm going to actively use this in our project. It would be a
perfect addition to the language as well.

As far as knowing when to use quotations is concerned, according to the
logic you have described, is that consistent behavior? In other words,
across all CMake commands, regardless of what the contents of a string is
(whitespace and whatnot), it is safe to pass it in without quotes unless it
may possibly be empty, in which case I'd use "${var}".

I agree that knowing when to use quotes can be confusing, but once you
understand a couple of rules it is pretty easy. Maybe you can give an
example of a more ambiguous case :)

Thanks again David.

---------
Robert Dailey


On Fri, Dec 9, 2011 at 9:27 AM, David Cole <david.cole at kitware.com> wrote:

> On Fri, Dec 9, 2011 at 9:59 AM, Robert Dailey <rcdailey at gmail.com> wrote:
> >
> > On Thu, Dec 8, 2011 at 7:59 PM, David Cole <david.cole at kitware.com>
> wrote:
> >>
> >> Well, nearly....
> >>
> >> You'll have to double-quote the "${documentation}" inside the function
> >> in case it is the empty string...
> >
> >
> > Or if it has spaces in it, right? Any time I have a string with spaces in
> > it, or that could have spaces in it, I use quotes so the value of the
> string
> > doesn't get interpreted as multiple parameters (like a list)
> >
>
> No, in this case, it's just in case it's empty because the CACHE form
> of set expects to get the type and the docstring following the CACHE
> keyword. If ${documentation} evaluates to the empty string, then the
> set command only "sees" 4 arguments and yields an error.
>
> The example CMakeLists file did have spaces in the documentation
> strings, but they worked just fine.
>
> In the case of set, the 5th argument can be ${documentation} or
> "${documentation}" as long as it's non-empty, and the results are
> equivalent. But if it's empty, the double-quoted form must be used.
>
> CMake's parser is the thing that splits at space boundaries when
> evaluating what to send into the set command. But since the actual
> literal code ${documentation} does not have spaces in it, it's full
> value (including any spaces in the value) get sent into the set
> command internally as arg 5.
>
> Understanding when you have to quote things is simply one of the
> hardest things to grok when dealing with CMake language code. Stick
> with it, though. It's easier than learning git. It only took me about
> 2 years of practice before I think something snapped into place in my
> brain...
>
>
> David
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111209/9777200f/attachment.htm>


More information about the CMake mailing list