<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 19, 2019 at 4:16 AM Kyle Edwards via CMake <<a href="mailto:cmake@cmake.org">cmake@cmake.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">On Mon, 2019-02-18 at 17:59 +0100, Andreas Naumann wrote:<br>
> Hey,<br>
> <br>
> I would introduce a list with the allowed values and introduce a<br>
> macro <br>
> "checked_set", which tests the setting or aborts.<br>
> <br>
> Regards,<br>
> Andreas"<br>
> <br>
> Am 18.02.19 um 15:06 schrieb <a href="mailto:Workbench@gmx.at" target="_blank">Workbench@gmx.at</a>:<br>
> > <br>
> > Hi everyone,<br>
> > <br>
> > i've looked the web but found no result. I need a string variable<br>
> > that <br>
> > allows only certain values, like bool variables only allow<br>
> > true/false <br>
> > my string should be either "A" or "B" ...<br>
<br>
Is this a cache variable or a regular variable? Cache variables have<br>
this enum-like support in the form of the STRINGS property. Example:<br>
<br>
set(MYSTRING "A" CACHE STRING "Documentation for the variable")<br>
set_property(CACHE MYSTRING PROPERTY STRINGS "A;B")<br></blockquote><div> </div><div>Note that this isn't an enforcing feature, only a convenience for CMake GUI and ccmake. It tells those tools what to show as selectable options for that cache variable, but you can still set the variable to anything you like via the cmake -D command line option or in the project itself.</div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com" target="_blank">https://crascit.com</a><br></div><div><br></div><div>Get the hand-book for every CMake user: <a href="https://crascit.com/professional-cmake/" target="_blank">Professional CMake: A Practical Guide</a><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div>