Hello,

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.

I would like to use three possible values for an option: AUTO (as default 
value), ON or OFF.

Example:
option(ENABLE_SOMETHING "Enable SOMETHING support" AUTO)

But of course this example is wrong because "AUTO" is not ON or OFF.

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.
It returns FALSE when the boolean constant is 0, OFF, NO, FALSE, N, IGNORE, 
NOTFOUND, the empty string, or ends in the suffix -NOTFOUND.

I would like to check the value myself.

Example:
if(ENABLE_SOMETHING=AUTO)
        message(STATUS "ENABLE_SOMETHING=AUTO")
endif()
if(ENABLE_SOMETHING=ON)
        message(STATUS "ENABLE_SOMETHING=ON")
endif()
if(ENABLE_SOMETHING=OFF)
        message(STATUS "ENABLE_SOMETHING=OFF")
endif()

But of course this example is wrong because "=" is not accepted for an 
expression in a "if" command.

So my question is: How to handle options with more than two possible values?

Thank you.
Best regards.

[1] https://cmake.org/cmake/help/v3.7/command/option.html
[2] https://cmake.org/cmake/help/v3.7/command/if.html
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to