On Fri, Dec 9, 2011 at 9:59 AM, Robert Dailey <rcdai...@gmail.com> wrote: > > On Thu, Dec 8, 2011 at 7:59 PM, David Cole <david.c...@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 -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake