]> git.lyx.org Git - features.git/commitdiff
Cmake build: Early check for wrong combo values
authorKornel Benko <kornel@lyx.org>
Mon, 9 Jun 2014 08:03:56 +0000 (10:03 +0200)
committerKornel Benko <kornel@lyx.org>
Mon, 9 Jun 2014 08:03:56 +0000 (10:03 +0200)
development/cmake/modules/LyXMacros.cmake

index 4332830c251357430e3d648fe62ebcf0c8ed5367..bcbca732e1700b7a0a6df5a1489fbd40474aa055 100644 (file)
@@ -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)