From cc6175bc96d03696dcd11bb207fc0f599a0947ab Mon Sep 17 00:00:00 2001 From: Kornel Benko Date: Mon, 9 Jun 2014 10:03:56 +0200 Subject: [PATCH] Cmake build: Early check for wrong combo values --- development/cmake/modules/LyXMacros.cmake | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/development/cmake/modules/LyXMacros.cmake b/development/cmake/modules/LyXMacros.cmake index 4332830c25..bcbca732e1 100644 --- a/development/cmake/modules/LyXMacros.cmake +++ b/development/cmake/modules/LyXMacros.cmake @@ -234,11 +234,19 @@ macro(LYX_OPTION _name _description _default _sys) endmacro() macro(LYX_COMBO _name _description _default) - set(LYX_${_name} ${_default} CACHE STRING "${_description}") - set_property(CACHE LYX_${_name} PROPERTY STRINGS ${_default} ${ARGN}) - list(APPEND LYX_OPTIONS LYX_${_name}) - set(LYX_${_name}_show_message ON) - set(LYX_${_name}_description ${_description}) + set(_lyx_name "LYX_${_name}") + set(${_lyx_name} ${_default} CACHE STRING "${_description}") + set(_combo_list ${_default} ${ARGN}) + set_property(CACHE ${_lyx_name} PROPERTY STRINGS ${_combo_list}) + 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() macro(LYX_OPTION_LIST_ALL)