Open
Description
Source: https://stackoverflow.com/a/62995653
Instead of mutually-exclusive set of options use a single parameter with a string value:
set(OPT "FIRST" CACHE STRING "Provider choosen")
This parameter is visible to the user in the same extent, as one created by option command.
Because the parameter can have only a single value, you needn't to check whether at most one of your options is enabled.
By assigning STRINGS
property of the parameter, you may tell a user which parameter's values can be used, and even provide drop-down list of them in the GUI:
set_property(CACHE OPT PROPERTY STRINGS "FIRST" "SECOND" "THIRD")
CMake itself doesn't check correctness of the parameter's value, but you may easily check it by yourself:
# Extract "STRINGS" property of the parameter
get_property(OPT_STRINGS CACHE OPT PROPERTY STRINGS)
# Check that value of the parameter is inside "STRINGS" list.
if (NOT OPT IN_LIST OPT_STRINGS)
message(FATAL_ERROR "Wrong value of the parameter 'OPT'")
endif
Metadata
Metadata
Assignees
Labels
No labels