Cmake build: Early check for wrong combo values

This commit is contained in:
Kornel Benko 2014-06-09 10:03:56 +02:00
parent 4cfc110d4a
commit cc6175bc96

View File

@ -234,11 +234,19 @@ macro(LYX_OPTION _name _description _default _sys)
endmacro() endmacro()
macro(LYX_COMBO _name _description _default) macro(LYX_COMBO _name _description _default)
set(LYX_${_name} ${_default} CACHE STRING "${_description}") set(_lyx_name "LYX_${_name}")
set_property(CACHE LYX_${_name} PROPERTY STRINGS ${_default} ${ARGN}) set(${_lyx_name} ${_default} CACHE STRING "${_description}")
list(APPEND LYX_OPTIONS LYX_${_name}) set(_combo_list ${_default} ${ARGN})
set(LYX_${_name}_show_message ON) set_property(CACHE ${_lyx_name} PROPERTY STRINGS ${_combo_list})
set(LYX_${_name}_description ${_description}) list(APPEND LYX_OPTIONS ${_lyx_name})
set(${_lyx_name}_show_message ON)
string(REGEX REPLACE ";" " " _use_list "${_combo_list}")
set(${_lyx_name}_description "${_description} (${_use_list})")
# Now check the value
list(FIND _combo_list ${${_lyx_name}} _idx)
if (_idx LESS 0)
message(FATAL_ERROR "${_lyx_name} set to \"${${_lyx_name}}\", but has to be only one of (${_use_list})")
endif()
endmacro() endmacro()
macro(LYX_OPTION_LIST_ALL) macro(LYX_OPTION_LIST_ALL)