[CMake] Modifying a variable's value without resetting the docstring

David Cole david.cole at kitware.com
Fri Sep 21 14:14:04 EDT 2012


On Fri, Sep 21, 2012 at 1:58 PM, David Doria <daviddoria at gmail.com> wrote:

> On Fri, Sep 21, 2012 at 1:44 PM, David Cole <david.cole at kitware.com>
> wrote:
> > You should avoid using FORCE in the first place.
> >
> > :-)
> >
> >
> > But if you have to use it, then you should provide the type and
> > documentation along with the call that uses FORCE. If you have multiple
> > calls that require this information, consider using variables to
> eliminate
> > the duplication and reference the variables from the multiple calls.
>
> I am using FORCE to do this:
>
> http://www.itk.org/Wiki/CMake/Tutorials/SettingVariableGroups
>
> You can see that my set(...FORCE...) call occurs inside of a foreach:
>
> set(${_var} OFF CACHE BOOL "test" FORCE)
>
> I guess to use your suggestion of making a variable that stores the
> docstring once and referencing it from multiple places I would have to
> use the CMake map emulation for this
> (http://www.cmake.org/Wiki/CMake:VariablesListsStrings#Emulating_maps)
> ? Sound like the right thing to do? Or is there an entirely better way
> to go about this :) ?
>
> Thanks,
>
> David
>


Well, if ${_var} is already a cache variable, you can retrieve it's
HELPSTRING property to see what was set as the original doc string. But if
it's not, then there won't be one, and you'll be adding an undocumented
option...


http://cmake.org/cmake/help/v2.8.9/cmake.html#section_PropertiesonCacheEntries
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120921/d5b6e50b/attachment.htm>


More information about the CMake mailing list