From 2dc84783fe3a33665c1017bd90975eff43e1196a Mon Sep 17 00:00:00 2001 From: Norbert Lange Date: Fri, 25 Dec 2020 22:11:49 +0100 Subject: [PATCH] CMake: Turn some property values into local arrays Update C/C++ Standards supported aswell --- src/_cmake | 77 ++++++++++++------------------------------------------ 1 file changed, 16 insertions(+), 61 deletions(-) diff --git a/src/_cmake b/src/_cmake index 925a81d..26c2185 100644 --- a/src/_cmake +++ b/src/_cmake @@ -402,6 +402,10 @@ _cmake_define_common_property_names() { _describe -t 'common-property-names' 'common property name' properties $@ } +local _cmake_build_types=('Debug' 'Release' 'RelWithDebInfo' 'MinSizeRel') +local _cmake_c_standards=(90 99 11) +local _cmake_cxx_standards=(98 11 14 17 20) + # ---------------------------- # _cmake_define_property_values # ---------------------------- @@ -410,67 +414,27 @@ _cmake_define_property_values() { local ret=1 setopt localoptions extendedglob case $@[-1] in - (CMAKE_BUILD_TYPE) _wanted build-types expl 'build type' _cmake_build_types && ret=0;; - (CMAKE_CXX_STANDARD) _wanted cxx-standards expl 'cxx standard' _cmake_cxx_standars && ret=0;; - (CMAKE_C_STANDARD) _wanted c-standards expl 'c standard' _cmake_c_standars && ret=0;; + (CMAKE_BUILD_TYPE) _wanted build-types expl 'build type' _values 'build type' ${_cmake_build_types[@]} && ret=0;; + (CMAKE_CXX_STANDARD) _wanted cxx-standards expl 'cxx standard' _values 'cxx standard' ${_cmake_cxx_standards[@]} && ret=0;; + (CMAKE_C_STANDARD) _wanted c-standards expl 'c standard' _values 'c standard' ${_cmake_c_standards[@]} && ret=0;; (CMAKE_TOOLCHAIN_FILE) _wanted toolchain-files expl 'file' _cmake_toolchain_files && ret=0;; - (CMAKE_COLOR_MAKEFILE) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; - (CMAKE_RULE_MESSAGES) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; - (CMAKE_VERBOSE_MAKEFILE) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; - (CMAKE_UNITY_BUILD) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; + (CMAKE_COLOR_MAKEFILE) _wanted booleans expl 'boolean' ${_cmake_booleans[@]} && ret=0;; + (CMAKE_RULE_MESSAGES) _wanted booleans expl 'boolean' ${_cmake_booleans[@]} && ret=0;; + (CMAKE_VERBOSE_MAKEFILE) _wanted booleans expl 'boolean' ${_cmake_booleans[@]} && ret=0;; + (CMAKE_UNITY_BUILD) _wanted booleans expl 'boolean' ${_cmake_booleans[@]} && ret=0;; (CMAKE_INSTALL_PREFIX) _files -/ && ret=0;; - (CMAKE_EXPORT_COMPILE_COMMANDS) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; + (CMAKE_EXPORT_COMPILE_COMMANDS) _wanted booleans expl 'boolean' ${_cmake_booleans[@]} && ret=0;; (CMAKE_*_COMPILER) _wanted compilers expl 'compiler' _cmake_compilers && ret=0;; (CMAKE_*_COMPILER_LAUNCHER) _wanted compilers expl 'compiler launcher' _cmake_launchers && ret=0;; (CMAKE_*_FLAGS(|_?*)) _message -e compiler-flags 'compiler flags' && _dispatch $service -value-,CPPFLAGS,-default- && ret=0;; - (CMAKE_*_STANDARD_REQUIRED) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; - (CMAKE_*_EXTENSIONS) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; + (CMAKE_*_STANDARD_REQUIRED) _wanted booleans expl 'boolean' ${_cmake_booleans[@]} && ret=0;; + (CMAKE_*_EXTENSIONS) _wanted booleans expl 'boolean' ${_cmake_booleans[@]} && ret=0;; (*) _files && ret=0;; esac return ret } -# ------------------ -# _cmake_build_types -# ------------------ -(( $+functions[_cmake_build_types] )) || -_cmake_build_types() { - local build_types; build_types=( - 'Debug' - 'Release' - 'RelWithDebInfo' - 'MinSizeRel' - ) - _values 'build type' ${build_types[@]} -} - -# ------------------- -# _cmake_c_standars -# ------------------- -(( $+functions[_cmake_c_standars] )) || -_cmake_c_standars() { - local c_standards; c_standards=( - '90' - '99' - '11' - ) - _values 'c standard' ${c_standards[@]} -} - -# ------------------- -# _cmake_cxx_standars -# ------------------- -(( $+functions[_cmake_cxx_standars] )) || -_cmake_cxx_standars() { - local cxx_standards; cxx_standards=( - '98' - '11' - '14' - '17' - ) - _values 'cxx standard' ${cxx_standards[@]} -} # ----------------- # _cmake_generators @@ -501,17 +465,8 @@ _cmake_toolchain_files() { _files -g '*\.cmake*' } -# --------------- -# _cmake_booleans -# --------------- -(( $+functions[_cmake_booleans] )) || -_cmake_booleans() { - local booleans; booleans=( - 'YES' - 'NO' - ) - _describe -t booleans 'boolean' booleans -} + +local _cmake_booleans=(_describe -t booleans 'boolean' 'YES' 'NO') # --------------- # _cmake_compilers