<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div>Hi.<br><br></div>option() is a handy shortcut for boolean options, but it's little more than syntactic sugar for a cache variable of type BOOL. To create a tristate variable, you can do this:<br><br></div>  set(ENABLE_SOMETHING AUTO CACHE STRING "Enable SOMETHING support")  # create the variable<br></div>  set_property(CACHE ENABLE_SOMETHING PROPERTY STRINGS AUTO ON OFF)  # define list of values GUI will offer for the variable<br><br></div>Then, you can test the variable like this:<br><br></div>  if(ENABLE_SOMETHING STREQUAL "AUTO")<br></div>    # AUTO was used<br></div>  elseif(ENABLE_SOMETHING)<br></div>    # a true value (such as ON) was used<br></div>  else()<br></div><div>    # a false value (such as OFF) was used<br></div>  endif()<br><br></div>Hope this helps.<br><br></div>Petr<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 13 October 2016 at 13:32, YuGiOhJCJ Mailing-List via CMake <span dir="ltr"><<a href="mailto:cmake@cmake.org" target="_blank">cmake@cmake.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
Regarding the cmake-commands manual [1], the "option" command seems to take as argument a boolean constant that can have the two possible values: ON or OFF.<br>
<br>
I would like to use three possible values for an option: AUTO (as default value), ON or OFF.<br>
<br>
Example:<br>
option(ENABLE_SOMETHING "Enable SOMETHING support" AUTO)<br>
<br>
But of course this example is wrong because "AUTO" is not ON or OFF.<br>
<br>
Regarding the cmake-commands manual [2], the "if" command seems to return TRUE when the boolean constant is 1, ON, YES, TRUE, Y, or a non-zero number.<br>
It returns FALSE when the boolean constant is 0, OFF, NO, FALSE, N, IGNORE, NOTFOUND, the empty string, or ends in the suffix -NOTFOUND.<br>
<br>
I would like to check the value myself.<br>
<br>
Example:<br>
if(ENABLE_SOMETHING=AUTO)<br>
        message(STATUS "ENABLE_SOMETHING=AUTO")<br>
endif()<br>
if(ENABLE_SOMETHING=ON)<br>
        message(STATUS "ENABLE_SOMETHING=ON")<br>
endif()<br>
if(ENABLE_SOMETHING=OFF)<br>
        message(STATUS "ENABLE_SOMETHING=OFF")<br>
endif()<br>
<br>
But of course this example is wrong because "=" is not accepted for an expression in a "if" command.<br>
<br>
So my question is: How to handle options with more than two possible values?<br>
<br>
Thank you.<br>
Best regards.<br>
<br>
[1] <a href="https://cmake.org/cmake/help/v3.7/command/option.html" rel="noreferrer" target="_blank">https://cmake.org/cmake/help/<wbr>v3.7/command/option.html</a><br>
[2] <a href="https://cmake.org/cmake/help/v3.7/command/if.html" rel="noreferrer" target="_blank">https://cmake.org/cmake/help/<wbr>v3.7/command/if.html</a><br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/<wbr>CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/cmake</a><br>
</blockquote></div><br></div>