Merge pull request #1235 from zsh-users/refactor_cmake

Refactor cmake completion
This commit is contained in:
Shohei YOSHIDA 2026-03-16 15:09:55 +09:00 committed by GitHub
commit 504b84f000
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 175 additions and 137 deletions

View File

@ -79,7 +79,7 @@ local -a cmake_build_options=(
'--list-presets[List available presets]' '--list-presets[List available presets]'
'--workflow[Run a workflow preset]' '--workflow[Run a workflow preset]'
'-E[CMake command mode]:command:_cmake_command_help' '-E[CMake command mode]:command:_cmake_commands'
'-L-[List cache variables]::_values "options" "[non-advanced cache variables]" "A[advanced cache variables]" "H[non-advanced cached variables with help]" "AH[advanced cache variables with help]"' '-L-[List cache variables]::_values "options" "[non-advanced cache variables]" "A[advanced cache variables]" "H[non-advanced cached variables with help]" "AH[advanced cache variables with help]"'
'--fresh[Configure a fresh build tree, removing any existing cache file]' '--fresh[Configure a fresh build tree, removing any existing cache file]'
@ -149,11 +149,11 @@ _cmake_generator_options() {
# -------------- # --------------
(( $+functions[_cmake_presets] )) || (( $+functions[_cmake_presets] )) ||
_cmake_presets() { _cmake_presets() {
local invoke; invoke=(${(Q)words}) local invoke=(${(Q)words})
invoke[$CURRENT]=() invoke[$CURRENT]=()
# TODO: remove all arguments -* except -S # TODO: remove all arguments -* except -S
local list_presets; list_presets=(${(f)"$(${invoke} --list-presets 2>/dev/null | local list_presets=(${(f)"$(${invoke} --list-presets 2>/dev/null |
sed -n -e 's,^[[:space:]]*"\([^"]*\)"[[:space:]]*-[[:space:]]*\(.*\),\1:\2,p' \ sed -n -e 's,^[[:space:]]*"\([^"]*\)"[[:space:]]*-[[:space:]]*\(.*\),\1:\2,p' \
-e 's,^[[:space:]]*"\([^"]*\)"[[:space:]]*$,\1,p')"}) -e 's,^[[:space:]]*"\([^"]*\)"[[:space:]]*$,\1,p')"})
@ -165,24 +165,16 @@ _cmake_presets() {
# -------------- # --------------
(( $+functions[_cmake_targets] )) || (( $+functions[_cmake_targets] )) ||
_cmake_targets() { _cmake_targets() {
local -a targets local dir="$1"
if [ -f $1/Makefile ] local -a targets=()
then if [[ -f "${dir}/Makefile" && $+commands[make] ]]; then
# `make help` doesn't work for Makefiles in general, but for CMake generated Makefiles it does. # `make help` doesn't work for Makefiles in general, but for CMake generated Makefiles it does.
i=1 targets=(${(f)"$(make -f $dir/Makefile help 2>/dev/null | awk '/^\.\.\./ { print $2 }')"})
for target in $(make -f $1/Makefile help | \grep -e "\.\.\." | sed "s/\.\.\. //" | sed "s/ (the default.*//") ; do elif [[ -f "${dir}/build.ninja" && $+commands[ninja] ]]; then
targets[$i]=$target
(( i = $i + 1 ))
done
elif [ -f $1/build.ninja ]
then
# `ninja help` doesn't seem to be the list of targets we're interested in # `ninja help` doesn't seem to be the list of targets we're interested in
i=1 targets=(${(f)"$(ninja -C $dir -t targets all 2>/dev/null | awk -F: '{print $1}' )"})
for target in $(ninja -C $1 -t targets all 2&>/dev/null | awk -F: '{print $1}') ; do
targets[$i]="$target"
(( i++ ))
done
fi fi
_describe 'build targets' targets _describe 'build targets' targets
} }
@ -195,44 +187,53 @@ _cmake_suggest_installdirs() {
} }
_cmake_on_build() { _cmake_on_build() {
local build_extras;build_extras=( local build_extras=(
'--[Native build tool options]' '--[Native build tool options]'
'--target[specify build target]' '--target[specify build target]'
'--clean-first[build target clean first]' '--clean-first[build target clean first]'
'--config[For multi-configuration tools]' '--config[For multi-configuration tools]'
'--parallel[maximum number of build processes]' '--parallel[maximum number of build processes]'
'--use-stderr') '--use-stderr'
)
local -a undescribed_build_extras local -a undescribed_build_extras
i=1 local i=1
for be in $build_extras ; do for be in $build_extras ; do
undescribed_build_extras[$i]=$(echo $be | sed "s/\[.*//") undescribed_build_extras[$i]=$(echo $be | sed "s/\[.*//")
(( i++ )) (( i++ ))
done done
inbuild=false
dashdashposition=-1 local in_build=false
local dash_dash_position=-1
local build_at=$CURRENT
for ((i = (($CURRENT - 1)); i > 1 ; i--)); do for ((i = (($CURRENT - 1)); i > 1 ; i--)); do
if [[ $words[$i] == --build ]] ; then if [[ $words[$i] == --build ]]; then
inbuild=true in_build=true
buildat=$i build_at=$i
(( difference = $CURRENT - $i )) (( difference = $CURRENT - $i ))
elif [[ $words[$i] == -- ]] ; then elif [[ $words[$i] == -- ]]; then
dashdashposition=$i dash_dash_position=$i
fi fi
done done
# check if build mode has been left # check if build mode has been left
outofbuild=false local out_of_build=false
for ((i = (($CURRENT - 1)); i > (($buildat + 1)); i--)); do for ((i = (($CURRENT - 1)); i > (($build_at + 1)); i--)); do
# don't check the word after --build (should be a directory) # don't check the word after --build (should be a directory)
if [[ ${undescribed_build_extras[(r)$words[$i]]} == $words[$i] ]] ; then continue ; fi if [[ ${undescribed_build_extras[(r)$words[$i]]} == $words[$i] ]]; then
if [[ $words[(($i - 1))] == --target ]] ; then continue ; fi continue
if [[ $words[(($i - 1))] == --config ]] ; then continue ; fi fi
if [[ $words[(($i - 1))] == --target ]]; then continue ; fi
if [[ $words[(($i - 1))] == --config ]]; then continue ; fi
if [[ $words[(($i - 1))] == --parallel ]] ; then continue ; fi if [[ $words[(($i - 1))] == --parallel ]] ; then continue ; fi
outofbuild=true out_of_build=true
done done
if (( $dashdashposition > 0 )) ; then
_cmake_generator_options $words[(($buildat + 1))] $dashdashposition && return 0 if (( $dash_dash_position > 0 )) ; then
_cmake_generator_options $words[(($build_at + 1))] $dash_dash_position && return 0
fi fi
if [[ "$inbuild" == false || "$difference" -eq 1 ]] ; then
if [[ "$in_build" == false || "$difference" -eq 1 ]] ; then
# either there is no --build or completing the directory after --build # either there is no --build or completing the directory after --build
_arguments -C -s \ _arguments -C -s \
- build_opts \ - build_opts \
@ -241,14 +242,14 @@ _cmake_on_build() {
"$cmake_suggest_build[@]" && return 0 "$cmake_suggest_build[@]" && return 0
elif [[ $words[(($CURRENT - 1))] == --target ]] ; then elif [[ $words[(($CURRENT - 1))] == --target ]] ; then
# after --build <dir> --target, suggest targets # after --build <dir> --target, suggest targets
_cmake_targets $words[(($buildat + 1))] && return 0 _cmake_targets $words[(($build_at + 1))] && return 0
elif [[ $words[(($CURRENT - 1))] == --config ]] ; then elif [[ $words[(($CURRENT - 1))] == --config ]] ; then
# after --build <dir> --config, no idea # after --build <dir> --config, no idea
return 0 return 0
elif [[ $words[(($CURRENT - 1))] == --parallel ]] ; then elif [[ $words[(($CURRENT - 1))] == --parallel ]] ; then
# after --build <dir> --parallel # after --build <dir> --parallel
return 0 return 0
elif [ "$outofbuild" = true ] ; then elif [ "$out_of_build" = true ] ; then
# after --build <dir> --<not a --build option>, suggest other cmake_build_options (like -Wno-dev) # after --build <dir> --<not a --build option>, suggest other cmake_build_options (like -Wno-dev)
_arguments "$cmake_build_options[@]" && return 0 _arguments "$cmake_build_options[@]" && return 0
else else
@ -258,43 +259,49 @@ _cmake_on_build() {
} }
_cmake_on_install() { _cmake_on_install() {
local build_extras;build_extras=( local build_extras=(
'--[Native build tool options]' '--[Native build tool options]'
'--prefix[Override the installation prefix, CMAKE_INSTALL_PREFIX]' '--prefix[Override the installation prefix, CMAKE_INSTALL_PREFIX]'
'--config[For multi-configuration generators(e.g. Visual Studio)]' '--config[For multi-configuration generators(e.g. Visual Studio)]'
'--component[Component-based install]' '--component[Component-based install]'
'--strip[Strip before installing.]' '--strip[Strip before installing.]'
) )
local -a undescribed_build_extras local -a undescribed_build_extras
i=1 local i=1
for be in $build_extras ; do for be in $build_extras ; do
undescribed_build_extras[$i]=$(echo $be | sed "s/\[.*//") undescribed_build_extras[$i]=$(echo $be | sed "s/\[.*//")
(( i++ )) (( i++ ))
done done
inbuild=false
dashdashposition=-1 local in_build=false
local dash_dash_position=-1
local build_at=$CURRENT
for ((i = (($CURRENT - 1)); i > 1 ; i--)); do for ((i = (($CURRENT - 1)); i > 1 ; i--)); do
if [[ $words[$i] == --install ]] ; then if [[ $words[$i] == --install ]]; then
inbuild=true in_build=true
buildat=$i build_at=$i
(( difference = $CURRENT - $i )) (( difference = $CURRENT - $i ))
elif [[ $words[$i] == -- ]] ; then elif [[ $words[$i] == -- ]]; then
dashdashposition=$i dash_dash_position=$i
fi fi
done done
outofbuild=false
for ((i = (($CURRENT - 1)); i > (($buildat + 1)); i--)); do local out_of_build=false
for ((i = (($CURRENT - 1)); i > (($build_at + 1)); i--)); do
# don't check the word after --install (should be a directory) # don't check the word after --install (should be a directory)
if [[ ${undescribed_build_extras[(r)$words[$i]]} == $words[$i] ]] ; then continue ; fi if [[ ${undescribed_build_extras[(r)$words[$i]]} == $words[$i] ]] ; then continue ; fi
if [[ $words[(($i - 1))] == --prefix ]] ; then continue ; fi if [[ $words[(($i - 1))] == --prefix ]]; then continue ; fi
if [[ $words[(($i - 1))] == --config ]] ; then continue ; fi if [[ $words[(($i - 1))] == --config ]]; then continue ; fi
if [[ $words[(($i - 1))] == --component ]] ; then continue ; fi if [[ $words[(($i - 1))] == --component ]]; then continue ; fi
outofbuild=true out_of_build=true
done done
if (( $dashdashposition > 0 )) ; then
_cmake_generator_options $words[(($buildat + 1))] $dashdashposition && return 0 if (( $dash_dash_position > 0 )) ; then
_cmake_generator_options $words[(($build_at + 1))] $dash_dash_position && return 0
fi fi
if [[ "$inbuild" == false || "$difference" -eq 1 ]] ; then
if [[ "$in_build" == false || "$difference" -eq 1 ]] ; then
# either there is no --install or completing the directory after --install # either there is no --install or completing the directory after --install
_arguments -C -s \ _arguments -C -s \
- build_opts \ - build_opts \
@ -310,7 +317,7 @@ _cmake_on_install() {
elif [[ $words[(($CURRENT - 1))] == --component ]] ; then elif [[ $words[(($CURRENT - 1))] == --component ]] ; then
# after --build <dir> --component, no idea # after --build <dir> --component, no idea
return 0 return 0
elif [ "$outofbuild" = true ] ; then elif [ "$out_of_build" = true ] ; then
# after --build <dir> --<not a --build option>, suggest other cmake_build_options (like -Wno-dev) # after --build <dir> --<not a --build option>, suggest other cmake_build_options (like -Wno-dev)
_arguments "$cmake_build_options[@]" && return 0 _arguments "$cmake_build_options[@]" && return 0
else else
@ -341,19 +348,16 @@ local -a cmake_help_actions=(
'(- 1)--help-variable-list[List variables with help available and exit]' '(- 1)--help-variable-list[List variables with help available and exit]'
'(- 1)--help-variables[Print cmake-variables manual and exit]' '(- 1)--help-variables[Print cmake-variables manual and exit]'
) )
_cmake_help() {
_arguments -C -s - help "$cmake_help_actions[@]"
}
# ----------------- # -----------------
# _cmake_list_names # _cmake_list_names
# ----------------- # -----------------
(( $+functions[_cmake_list_names] )) || (( $+functions[_cmake_list_names] )) ||
_cmake_list_names() { _cmake_list_names() {
local command; command="$@[1]" local command="$@[1]"
local desc; desc="$@[2]" local desc="$@[2]"
local opts; opts=($@[3]) local opts=($@[3])
local list_names; list_names=(${(f)"$($service $command 2> /dev/null)"}) local list_names=(${(f)"$($service $command 2> /dev/null)"})
# Older CMake (< 3.0) writes out the version # Older CMake (< 3.0) writes out the version
list_names=(${^list_names##cmake version*}) list_names=(${^list_names##cmake version*})
@ -382,7 +386,7 @@ _cmake_define_property() {
# ---------------------------- # ----------------------------
(( $+functions[_cmake_define_property_names] )) || (( $+functions[_cmake_define_property_names] )) ||
_cmake_define_property_names() { _cmake_define_property_names() {
local alternatives; alternatives=( local alternatives=(
'common-property-names:common property name:_cmake_define_common_property_names -qS=' 'common-property-names:common property name:_cmake_define_common_property_names -qS='
) )
local -A cmake_langs local -A cmake_langs
@ -402,8 +406,9 @@ _cmake_define_property_names() {
# --------------------------------- # ---------------------------------
(( $+functions[_cmake_define_lang_property_names] )) || (( $+functions[_cmake_define_lang_property_names] )) ||
_cmake_define_lang_property_names() { _cmake_define_lang_property_names() {
local cmake_lang="$@[-2]" cmake_lang_desc="$@[-1]" local cmake_lang="$@[-2]"
local properties; properties=( local cmake_lang_desc="$@[-1]"
local -a properties=(
"CMAKE_${cmake_lang}_COMPILER:${cmake_lang_desc} compiler" "CMAKE_${cmake_lang}_COMPILER:${cmake_lang_desc} compiler"
"CMAKE_${cmake_lang}_COMPILER_LAUNCHER:${cmake_lang_desc} compiler launcher (e.g. ccache)" "CMAKE_${cmake_lang}_COMPILER_LAUNCHER:${cmake_lang_desc} compiler launcher (e.g. ccache)"
"CMAKE_${cmake_lang}_FLAGS:${cmake_lang_desc} compiler flags for all builds" "CMAKE_${cmake_lang}_FLAGS:${cmake_lang_desc} compiler flags for all builds"
@ -424,7 +429,7 @@ _cmake_define_lang_property_names() {
# ----------------------------------- # -----------------------------------
(( $+functions[_cmake_define_common_property_names] )) || (( $+functions[_cmake_define_common_property_names] )) ||
_cmake_define_common_property_names() { _cmake_define_common_property_names() {
local properties; properties=( local -a properties=(
'CMAKE_MODULE_PATH:Search path for CMake modules (FindPROJECT.cmake)' 'CMAKE_MODULE_PATH:Search path for CMake modules (FindPROJECT.cmake)'
'CMAKE_PREFIX_PATH:Search path for installations (PROJECTConfig.cmake)' 'CMAKE_PREFIX_PATH:Search path for installations (PROJECTConfig.cmake)'
'CMAKE_BUILD_TYPE:Specifies the build type for make based generators' 'CMAKE_BUILD_TYPE:Specifies the build type for make based generators'
@ -438,51 +443,87 @@ _cmake_define_common_property_names() {
'CMAKE_UNITY_BUILD:Batch include source files' 'CMAKE_UNITY_BUILD:Batch include source files'
) )
_describe -t 'common-property-names' 'common property name' properties $@ _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 # _cmake_define_property_values
# ---------------------------- # ----------------------------
(( $+functions[_cmake_define_property_values] )) || (( $+functions[_cmake_define_property_values] )) ||
_cmake_define_property_values() { _cmake_define_property_values() {
local ret=1 local ret=1
local build_types=('Debug' 'Release' 'RelWithDebInfo' 'MinSizeRel')
local c_standards=(90 99 11 17 23)
local cxx_standards=(98 11 14 17 20 23)
setopt localoptions extendedglob setopt localoptions extendedglob
case $@[-1] in case $@[-1] in
(CMAKE_BUILD_TYPE) _wanted build-types expl 'build type' _values 'build type' ${_cmake_build_types[@]} && ret=0;; (CMAKE_BUILD_TYPE)
(BUILD_SHARED_LIBS) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; _wanted build-types expl 'build type' _values 'build type' ${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;; (BUILD_SHARED_LIBS)
(CMAKE_TOOLCHAIN_FILE) _wanted toolchain-files expl 'file' _cmake_toolchain_files && ret=0;; _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_CXX_STANDARD)
(CMAKE_VERBOSE_MAKEFILE) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; _wanted cxx-standards expl 'cxx standard' _values 'cxx standard' ${cxx_standards[@]} && ret=0
(CMAKE_UNITY_BUILD) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; ;;
(CMAKE_INSTALL_PREFIX) _files -/ && ret=0;; (CMAKE_C_STANDARD)
(CMAKE_EXPORT_COMPILE_COMMANDS) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; _wanted c-standards expl 'c standard' _values 'c standard' ${c_standards[@]} && 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_TOOLCHAIN_FILE)
(CMAKE_*_FLAGS(|_?*)) _message -e compiler-flags 'compiler flags' && _dispatch $service -value-,CPPFLAGS,-default- && ret=0;; _wanted toolchain-files expl 'file' _cmake_toolchain_files && ret=0
(CMAKE_*_STANDARD_REQUIRED) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; ;;
(CMAKE_*_EXTENSIONS) _wanted booleans expl 'boolean' _cmake_booleans && ret=0;; (CMAKE_COLOR_MAKEFILE)
(*) _files && ret=0;; _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_*_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
;;
(*)
_files && ret=0
;;
esac esac
return ret return ret
} }
local -a _cmake_generator_list=(${(f)"$(cmake --help | awk '/^Generators/{flag=1} flag && /^[* ] [^ ]/ {sub(/^[* ] /, ""); sub(/=.*$/, ""); sub(/\[arch\]/, ""); sub(/ *$/, ""); print}')"})
# ----------------- # -----------------
# _cmake_generators # _cmake_generators
# ----------------- # -----------------
(( $+functions[_cmake_generators] )) || (( $+functions[_cmake_generators] )) ||
_cmake_generators() { _cmake_generators() {
_describe -t generators 'generator' _cmake_generator_list local -a generators=(
${(f)"$(cmake --help | awk '/^Generators/{flag=1} flag && /^[* ] [^ ]/ {sub(/^[* ] /, ""); sub(/=.*$/, ""); sub(/\[arch\]/, ""); sub(/ *$/, ""); print}')"}
)
_describe -t generators 'generator' generators
} }
# ---------------------- # ----------------------
@ -519,45 +560,46 @@ _cmake_launchers() {
_command_names -e _command_names -e
} }
local -a _cmake_commands=( (( $+functions[_cmake_commands] )) ||
'capabilities:Report capabilities built into cmake in JSON format' \ _cmake_commands() {
'cat:concat the files and print them to the standard output' \ local -a commands=(
'chdir:run command in a given directory' \ 'capabilities:Report capabilities built into cmake in JSON format'
'compare_files:check if file1 is same as file2' \ 'cat:concat the files and print them to the standard output'
'copy:copy files to destination (either file or directory)' \ 'chdir:run command in a given directory'
'copy_directory:copy content of <dir>... directories to destination directory' \ 'compare_files:check if file1 is same as file2'
'copy_if_different:copy files if it has changed' \ 'copy:copy files to destination (either file or directory)'
'echo:displays arguments as text' \ 'copy_directory:copy content of <dir>... directories to destination directory'
'echo_append:displays arguments as text but no new line' \ 'copy_if_different:copy files if it has changed'
'env:run command in a modified environment' \ 'echo:displays arguments as text'
'environment:display the current environment' \ 'echo_append:displays arguments as text but no new line'
'make_directory:create parent and <dir> directories' \ 'env:run command in a modified environment'
'md5sum:create MD5 checksum of files' \ 'environment:display the current environment'
'sha1sum:create SHA1 checksum of files' \ 'make_directory:create parent and <dir> directories'
'sha224sum:create SHA224 checksum of files' \ 'md5sum:create MD5 checksum of files'
'sha256sum:create SHA256 checksum of files' \ 'sha1sum:create SHA1 checksum of files'
'sha384sum:create SHA384 checksum of files' \ 'sha224sum:create SHA224 checksum of files'
'sha512sum:create SHA512 checksum of files' \ 'sha256sum:create SHA256 checksum of files'
'remove:remove the file(s), use -f to force it' \ 'sha384sum:create SHA384 checksum of files'
'remove_directory:remove directories and their contents' \ 'sha512sum:create SHA512 checksum of files'
'rename:rename a file or directory (on one volume)' \ 'remove:remove the file(s), use -f to force it'
'rm:remove files or directories' \ 'remove_directory:remove directories and their contents'
'server:start cmake in server mode' \ 'rename:rename a file or directory (on one volume)'
'sleep:sleep for given number of seconds' \ 'rm:remove files or directories'
'tar:create or extract a tar or zip archive' \ 'server:start cmake in server mode'
'time:run command and display elapsed time' \ 'sleep:sleep for given number of seconds'
'touch:touch a <file>' \ 'tar:create or extract a tar or zip archive'
'touch_nocreate:touch a <file> but do not create it' \ 'time:run command and display elapsed time'
'create_symlink:create a symbolic link new -> old' \ 'touch:touch a <file>'
'create_hardlink:create a hard link new -> old' \ 'touch_nocreate:touch a <file> but do not create it'
'true:do nothing with an exit code of 0' \ 'create_symlink:create a symbolic link new -> old'
'false:do nothing with an exit code of 1' 'create_hardlink:create a hard link new -> old'
) 'true:do nothing with an exit code of 0'
_cmake_command() { 'false:do nothing with an exit code of 1'
_arguments -C \ )
'-E[CMake command mode]:command:(("${_cmake_commands[@]}"))'
_describe -t commands 'command' commands
} }
local cmake_suggest_build;cmake_suggest_build=( local cmake_suggest_build;cmake_suggest_build=(
'--build[build]:build dir:_cmake_suggest_builddirs' '--build[build]:build dir:_cmake_suggest_builddirs'
) )
@ -573,21 +615,17 @@ elif [ $CURRENT -eq 2 ] ; then
- help \ - help \
"$cmake_help_actions[@]" \ "$cmake_help_actions[@]" \
- command \ - command \
'-E[CMake command mode]:command:( )' \ '-E[CMake command mode]:command:_cmake_commands' \
- build_opts \ - build_opts \
"$cmake_build_options[@]" \ "$cmake_build_options[@]" \
- build_cmds \ - build_cmds \
"$cmake_suggest_build[@]" \ "$cmake_suggest_build[@]" \
- install_cmds \ - install_cmds \
"$cmake_suggest_install[@]" && return 0 "$cmake_suggest_install[@]" && return 0
elif [[ $words[2] = --help* ]] ; then
_cmake_help
elif [[ $words[2] == --build ]] ; then elif [[ $words[2] == --build ]] ; then
_cmake_on_build _cmake_on_build
elif [[ $words[2] == --install ]] ; then elif [[ $words[2] == --install ]] ; then
_cmake_on_install _cmake_on_install
elif [[ $words[2] == -E ]]; then
_cmake_command
else else
_arguments "$cmake_build_options[@]" _arguments "$cmake_build_options[@]"
fi fi