summaryrefslogtreecommitdiffstats
path: root/Auxiliary
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-09-23 18:30:25 (GMT)
committerBrad King <brad.king@kitware.com>2013-10-15 14:46:54 (GMT)
commitb601e2350afa89e592c4a601b08f8c74728d1ae3 (patch)
tree24db537acd620a356e1daf25d9e2d050d50f382d /Auxiliary
parent07b80021aad97a4f4243e97576bae4670114a3ca (diff)
downloadCMake-b601e2350afa89e592c4a601b08f8c74728d1ae3.zip
CMake-b601e2350afa89e592c4a601b08f8c74728d1ae3.tar.gz
CMake-b601e2350afa89e592c4a601b08f8c74728d1ae3.tar.bz2
Rename Docs to Auxiliary
The directory contains auxiliary support files for integration with other tools, not documentation.
Diffstat (limited to 'Auxiliary')
-rw-r--r--Auxiliary/CMakeLists.txt3
-rw-r--r--Auxiliary/bash-completion/CMakeLists.txt8
-rw-r--r--Auxiliary/bash-completion/cmake151
-rw-r--r--Auxiliary/bash-completion/cpack61
-rw-r--r--Auxiliary/bash-completion/ctest81
-rw-r--r--Auxiliary/cmake-help.vim21
-rw-r--r--Auxiliary/cmake-indent.vim93
-rw-r--r--Auxiliary/cmake-mode.el357
-rw-r--r--Auxiliary/cmake-syntax.vim89
9 files changed, 864 insertions, 0 deletions
diff --git a/Auxiliary/CMakeLists.txt b/Auxiliary/CMakeLists.txt
new file mode 100644
index 0000000..34090d2
--- /dev/null
+++ b/Auxiliary/CMakeLists.txt
@@ -0,0 +1,3 @@
+install(FILES cmake-help.vim cmake-indent.vim cmake-syntax.vim DESTINATION ${CMAKE_DATA_DIR}/editors/vim)
+install(FILES cmake-mode.el DESTINATION ${CMAKE_DATA_DIR}/editors/emacs)
+add_subdirectory (bash-completion)
diff --git a/Auxiliary/bash-completion/CMakeLists.txt b/Auxiliary/bash-completion/CMakeLists.txt
new file mode 100644
index 0000000..c0a8899
--- /dev/null
+++ b/Auxiliary/bash-completion/CMakeLists.txt
@@ -0,0 +1,8 @@
+# Always install completion file in local dir
+# in order to be sure to always be able to install
+# in a local user directory rooted in a single directory.
+# packager should either patch that out or
+# add symlinks to the files in appropriate places
+# /etc/bash_completion.d/
+# DATADIR/completions (may be /usr/share/<package>/completions
+install(FILES cmake cpack ctest DESTINATION ${CMAKE_DATA_DIR}/completions)
diff --git a/Auxiliary/bash-completion/cmake b/Auxiliary/bash-completion/cmake
new file mode 100644
index 0000000..59e0298
--- /dev/null
+++ b/Auxiliary/bash-completion/cmake
@@ -0,0 +1,151 @@
+# bash completion for cmake(1) -*- shell-script -*-
+
+_cmake()
+{
+ local cur prev words cword split=false
+ _init_completion -n := || return
+
+ # Workaround for options like -DCMAKE_BUILD_TYPE=Release
+ local prefix=
+ if [[ $cur == -D* ]]; then
+ prev=-D
+ prefix=-D
+ cur="${cur#-D}"
+ elif [[ $cur == -U* ]]; then
+ prev=-U
+ prefix=-U
+ cur="${cur#-U}"
+ fi
+
+ case "$prev" in
+ -D)
+ if [[ $cur == *=* ]]; then
+ # complete values for variables
+ local var type value
+ var="${cur%%[:=]*}"
+ value="${cur#*=}"
+
+ if [[ $cur == CMAKE_BUILD_TYPE* ]]; then # most widely used case
+ COMPREPLY=( $( compgen -W 'Debug Release RelWithDebInfo
+ MinSizeRel' -- "$value" ) )
+ return
+ fi
+
+ if [[ $cur == *:* ]]; then
+ type="${cur#*:}"
+ type="${type%%=*}"
+ else # get type from cache if it's not set explicitly
+ type=$( cmake -LA -N 2>/dev/null | grep "$var:" \
+ 2>/dev/null )
+ type="${type#*:}"
+ type="${type%%=*}"
+ fi
+ case "$type" in
+ FILEPATH)
+ cur="$value"
+ _filedir
+ return
+ ;;
+ PATH)
+ cur="$value"
+ _filedir -d
+ return
+ ;;
+ BOOL)
+ COMPREPLY=( $( compgen -W 'ON OFF TRUE FALSE' -- \
+ "$value" ) )
+ return
+ ;;
+ STRING|INTERNAL)
+ # no completion available
+ return
+ ;;
+ esac
+ elif [[ $cur == *:* ]]; then
+ # complete types
+ local type="${cur#*:}"
+ COMPREPLY=( $( compgen -W 'FILEPATH PATH STRING BOOL INTERNAL'\
+ -S = -- "$type" ) )
+ compopt -o nospace
+ else
+ # complete variable names
+ COMPREPLY=( $( compgen -W '$( cmake -LA -N | tail -n +2 |
+ cut -f1 -d: )' -P "$prefix" -- "$cur" ) )
+ compopt -o nospace
+ fi
+ return
+ ;;
+ -U)
+ COMPREPLY=( $( compgen -W '$( cmake -LA -N | tail -n +2 |
+ cut -f1 -d: )' -P "$prefix" -- "$cur" ) )
+ return
+ ;;
+ esac
+
+ _split_longopt && split=true
+
+ case "$prev" in
+ -C|-P|--graphviz|--system-information)
+ _filedir
+ return
+ ;;
+ --build)
+ _filedir -d
+ return
+ ;;
+ -E)
+ COMPREPLY=( $( compgen -W "$( cmake -E help |& sed -n \
+ '/^ /{s|^ \([^ ]\{1,\}\) .*$|\1|;p}' 2>/dev/null )" \
+ -- "$cur" ) )
+ return
+ ;;
+ -G)
+ local IFS=$'\n'
+ local quoted
+ printf -v quoted %q "$cur"
+ COMPREPLY=( $( compgen -W '$( cmake --help 2>/dev/null | sed -n \
+ -e "1,/^Generators/d" \
+ -e "/^ *[^ =]/{s|^ *\([^=]*[^ =]\).*$|\1|;s| |\\\\ |g;p}" \
+ 2>/dev/null )' -- "$quoted" ) )
+ return
+ ;;
+ --help-command)
+ COMPREPLY=( $( compgen -W '$( cmake --help-command-list 2>/dev/null|
+ grep -v "^cmake version " )' -- "$cur" ) )
+ return
+ ;;
+ --help-module)
+ COMPREPLY=( $( compgen -W '$( cmake --help-module-list 2>/dev/null|
+ grep -v "^cmake version " )' -- "$cur" ) )
+ return
+ ;;
+ --help-policy)
+ COMPREPLY=( $( compgen -W '$( cmake --help-policies 2>/dev/null |
+ grep "^ CMP" 2>/dev/null )' -- "$cur" ) )
+ return
+ ;;
+ --help-property)
+ COMPREPLY=( $( compgen -W '$( cmake --help-property-list \
+ 2>/dev/null | grep -v "^cmake version " )' -- "$cur" ) )
+ return
+ ;;
+ --help-variable)
+ COMPREPLY=( $( compgen -W '$( cmake --help-variable-list \
+ 2>/dev/null | grep -v "^cmake version " )' -- "$cur" ) )
+ return
+ ;;
+ esac
+
+ $split && return
+
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $(compgen -W '$( _parse_help "$1" --help )' -- ${cur}) )
+ [[ $COMPREPLY == *= ]] && compopt -o nospace
+ [[ $COMPREPLY ]] && return
+ fi
+
+ _filedir
+} &&
+complete -F _cmake cmake
+
+# ex: ts=4 sw=4 et filetype=sh
diff --git a/Auxiliary/bash-completion/cpack b/Auxiliary/bash-completion/cpack
new file mode 100644
index 0000000..9ab6048
--- /dev/null
+++ b/Auxiliary/bash-completion/cpack
@@ -0,0 +1,61 @@
+# bash completion for cpack(1) -*- shell-script -*-
+
+_cpack()
+{
+ local cur prev words cword
+ _init_completion -n = || return
+
+ case "$prev" in
+ -G)
+ COMPREPLY=( $( compgen -W '$( cpack --help 2>/dev/null |
+ sed -e "1,/^Generators/d" -e "s|^ *\([^ ]*\) .*$|\1|" \
+ 2>/dev/null )' -- "$cur" ) )
+ return
+ ;;
+ -C)
+ COMPREPLY=( $( compgen -W 'Debug Release RelWithDebInfo
+ MinSizeRel' -- "$cur" ) )
+ return
+ ;;
+ -D)
+ [[ $cur == *=* ]] && return # no completion for values
+ COMPREPLY=( $( compgen -W '$( cpack --help-variable-list \
+ 2>/dev/null | grep -v "^cpack version " )' -S = -- "$cur" ) )
+ compopt -o nospace
+ return
+ ;;
+ -P|-R|--vendor)
+ # argument required but no completions available
+ return
+ ;;
+ -B)
+ _filedir -d
+ return
+ ;;
+ --config)
+ _filedir
+ return
+ ;;
+ --help-command)
+ COMPREPLY=( $( compgen -W '$( cpack --help-command-list 2>/dev/null|
+ grep -v "^cpack version " )' -- "$cur" ) )
+ return
+ ;;
+ --help-variable)
+ COMPREPLY=( $( compgen -W '$( cpack --help-variable-list \
+ 2>/dev/null | grep -v "^cpack version " )' -- "$cur" ) )
+ return
+ ;;
+ esac
+
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $(compgen -W '$( _parse_help "$1" --help )' -- ${cur}) )
+ [[ $COMPREPLY == *= ]] && compopt -o nospace
+ [[ $COMPREPLY ]] && return
+ fi
+
+ _filedir
+} &&
+complete -F _cpack cpack
+
+# ex: ts=4 sw=4 et filetype=sh
diff --git a/Auxiliary/bash-completion/ctest b/Auxiliary/bash-completion/ctest
new file mode 100644
index 0000000..25cb998
--- /dev/null
+++ b/Auxiliary/bash-completion/ctest
@@ -0,0 +1,81 @@
+# bash completion for ctest(1) -*- shell-script -*-
+
+_ctest()
+{
+ local cur prev words cword
+ _init_completion -n = || return
+
+ case "$prev" in
+ -C|--build-config)
+ COMPREPLY=( $( compgen -W 'Debug Release RelWithDebInfo
+ MinSizeRel' -- "$cur" ) )
+ return
+ ;;
+ -j|--parallel)
+ COMPREPLY=( $( compgen -W "{1..$(( $(_ncpus)*2 ))}" -- "$cur" ) )
+ return
+ ;;
+ -O|--output-log|-A|--add-notes|--extra-submit)
+ _filedir
+ return
+ ;;
+ -L|--label-regex|-LE|--label-exclude|--track|-I|--tests-information|\
+ --max-width|--timeout|--stop-time)
+ # argument required but no completions available
+ return
+ ;;
+ -R|--tests-regex|-E|--exclude-regex)
+ COMPREPLY=( $( compgen -W '$( ctest -N 2>/dev/null |
+ grep "^ Test" 2>/dev/null | cut -d: -f 2 )' -- "$cur" ) )
+ return
+ ;;
+ -D|--dashboard)
+ if [[ $cur == @(Experimental|Nightly|Continuous)* ]]; then
+ local model action
+ action=${cur#@(Experimental|Nightly|Continuous)}
+ model=${cur%"$action"}
+ COMPREPLY=( $( compgen -W 'Start Update Configure Build Test
+ Coverage Submit MemCheck' -P "$model" -- "$action" ) )
+ else
+ COMPREPLY=( $( compgen -W 'Experimental Nightly Continuous' \
+ -- "$cur" ) )
+ compopt -o nospace
+ fi
+ return
+ ;;
+ -M|--test-model)
+ COMPREPLY=( $( compgen -W 'Experimental Nightly Continuous' -- \
+ "$cur" ) )
+ return
+ ;;
+ -T|--test-action)
+ COMPREPLY=( $( compgen -W 'Start Update Configure Build Test
+ Coverage Submit MemCheck' -- "$cur" ) )
+ return
+ ;;
+ -S|--script|-SP|--script-new-process)
+ _filedir '@(cmake|ctest)'
+ return
+ ;;
+ --interactive-debug-mode)
+ COMPREPLY=( $( compgen -W '0 1' -- "$cur" ) )
+ return
+ ;;
+ --help-command)
+ COMPREPLY=( $( compgen -W '$( ctest --help-command-list 2>/dev/null|
+ grep -v "^ctest version " )' -- "$cur" ) )
+ return
+ ;;
+ esac
+
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $(compgen -W '$( _parse_help "$1" --help )' -- ${cur}) )
+ [[ $COMPREPLY == *= ]] && compopt -o nospace
+ [[ $COMPREPLY ]] && return
+ fi
+
+ _filedir
+} &&
+complete -F _ctest ctest
+
+# ex: ts=4 sw=4 et filetype=sh
diff --git a/Auxiliary/cmake-help.vim b/Auxiliary/cmake-help.vim
new file mode 100644
index 0000000..17cfa83
--- /dev/null
+++ b/Auxiliary/cmake-help.vim
@@ -0,0 +1,21 @@
+nmap ,hc :call OpenCmakeHelp()<CR>
+
+function! OpenCmakeHelp()
+ let s = getline( '.' )
+ let i = col( '.' ) - 1
+ while i > 0 && strpart( s, i, 1 ) =~ '[A-Za-z0-9_]'
+ let i = i - 1
+ endwhile
+ while i < col('$') && strpart( s, i, 1 ) !~ '[A-Za-z0-9_]'
+ let i = i + 1
+ endwhile
+ let start = match( s, '[A-Za-z0-9_]\+', i )
+ let end = matchend( s, '[A-Za-z0-9_]\+', i )
+ let ident = strpart( s, start, end - start )
+ execute "vertical new"
+ execute "%!cmake --help-command ".ident
+ set nomodified
+ set readonly
+endfunction
+
+autocmd BufRead,BufNewFile *.cmake,CMakeLists.txt,*.cmake.in nmap <F1> :call OpenCmakeHelp()<CR>
diff --git a/Auxiliary/cmake-indent.vim b/Auxiliary/cmake-indent.vim
new file mode 100644
index 0000000..a26dd06
--- /dev/null
+++ b/Auxiliary/cmake-indent.vim
@@ -0,0 +1,93 @@
+" =============================================================================
+"
+" Program: CMake - Cross-Platform Makefile Generator
+" Module: $RCSfile$
+" Language: VIM
+" Date: $Date$
+" Version: $Revision$
+"
+" =============================================================================
+
+" Vim indent file
+" Language: CMake (ft=cmake)
+" Author: Andy Cedilnik <andy.cedilnik@kitware.com>
+" Maintainer: Karthik Krishnan <karthik.krishnan@kitware.com>
+" Last Change: $Date$
+" Version: $Revision$
+"
+" Licence: The CMake license applies to this file. See
+" http://www.cmake.org/HTML/Copyright.html
+" This implies that distribution with Vim is allowed
+
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=CMakeGetIndent(v:lnum)
+setlocal indentkeys+==ENDIF(,ENDFOREACH(,ENDMACRO(,ELSE(,ELSEIF(,ENDWHILE(
+
+" Only define the function once.
+if exists("*CMakeGetIndent")
+ finish
+endif
+
+fun! CMakeGetIndent(lnum)
+ let this_line = getline(a:lnum)
+
+ " Find a non-blank line above the current line.
+ let lnum = a:lnum
+ let lnum = prevnonblank(lnum - 1)
+ let previous_line = getline(lnum)
+
+ " Hit the start of the file, use zero indent.
+ if lnum == 0
+ return 0
+ endif
+
+ let ind = indent(lnum)
+
+ let or = '\|'
+ " Regular expressions used by line indentation function.
+ let cmake_regex_comment = '#.*'
+ let cmake_regex_identifier = '[A-Za-z][A-Za-z0-9_]*'
+ let cmake_regex_quoted = '"\([^"\\]\|\\.\)*"'
+ let cmake_regex_arguments = '\(' . cmake_regex_quoted .
+ \ or . '\$(' . cmake_regex_identifier . ')' .
+ \ or . '[^()\\#"]' . or . '\\.' . '\)*'
+
+ let cmake_indent_comment_line = '^\s*' . cmake_regex_comment
+ let cmake_indent_blank_regex = '^\s*$'
+ let cmake_indent_open_regex = '^\s*' . cmake_regex_identifier .
+ \ '\s*(' . cmake_regex_arguments .
+ \ '\(' . cmake_regex_comment . '\)\?$'
+
+ let cmake_indent_close_regex = '^' . cmake_regex_arguments .
+ \ ')\s*' .
+ \ '\(' . cmake_regex_comment . '\)\?$'
+
+ let cmake_indent_begin_regex = '^\s*\(IF\|MACRO\|FOREACH\|ELSE\|ELSEIF\|WHILE\|FUNCTION\)\s*('
+ let cmake_indent_end_regex = '^\s*\(ENDIF\|ENDFOREACH\|ENDMACRO\|ELSE\|ELSEIF\|ENDWHILE\|ENDFUNCTION\)\s*('
+
+ " Add
+ if previous_line =~? cmake_indent_comment_line " Handle comments
+ let ind = ind
+ else
+ if previous_line =~? cmake_indent_begin_regex
+ let ind = ind + &sw
+ endif
+ if previous_line =~? cmake_indent_open_regex
+ let ind = ind + &sw
+ endif
+ endif
+
+ " Subtract
+ if this_line =~? cmake_indent_end_regex
+ let ind = ind - &sw
+ endif
+ if previous_line =~? cmake_indent_close_regex
+ let ind = ind - &sw
+ endif
+
+ return ind
+endfun
diff --git a/Auxiliary/cmake-mode.el b/Auxiliary/cmake-mode.el
new file mode 100644
index 0000000..6feed94
--- /dev/null
+++ b/Auxiliary/cmake-mode.el
@@ -0,0 +1,357 @@
+;=============================================================================
+; CMake - Cross Platform Makefile Generator
+; Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
+;
+; Distributed under the OSI-approved BSD License (the "License");
+; see accompanying file Copyright.txt for details.
+;
+; This software is distributed WITHOUT ANY WARRANTY; without even the
+; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+; See the License for more information.
+;=============================================================================
+;;; cmake-mode.el --- major-mode for editing CMake sources
+
+;------------------------------------------------------------------------------
+
+;;; Commentary:
+
+;; Provides syntax highlighting and indentation for CMakeLists.txt and
+;; *.cmake source files.
+;;
+;; Add this code to your .emacs file to use the mode:
+;;
+;; (setq load-path (cons (expand-file-name "/dir/with/cmake-mode") load-path))
+;; (require 'cmake-mode)
+;; (setq auto-mode-alist
+;; (append '(("CMakeLists\\.txt\\'" . cmake-mode)
+;; ("\\.cmake\\'" . cmake-mode))
+;; auto-mode-alist))
+
+;------------------------------------------------------------------------------
+
+;;; Code:
+;;
+;; cmake executable variable used to run cmake --help-command
+;; on commands in cmake-mode
+;;
+;; cmake-command-help Written by James Bigler
+;;
+
+(defcustom cmake-mode-cmake-executable "cmake"
+ "*The name of the cmake executable.
+
+This can be either absolute or looked up in $PATH. You can also
+set the path with these commands:
+ (setenv \"PATH\" (concat (getenv \"PATH\") \";C:\\\\Program Files\\\\CMake 2.8\\\\bin\"))
+ (setenv \"PATH\" (concat (getenv \"PATH\") \":/usr/local/cmake/bin\"))"
+ :type 'file
+ :group 'cmake)
+;;
+;; Regular expressions used by line indentation function.
+;;
+(defconst cmake-regex-blank "^[ \t]*$")
+(defconst cmake-regex-comment "#.*")
+(defconst cmake-regex-paren-left "(")
+(defconst cmake-regex-paren-right ")")
+(defconst cmake-regex-argument-quoted
+ "\"\\([^\"\\\\]\\|\\\\\\(.\\|\n\\)\\)*\"")
+(defconst cmake-regex-argument-unquoted
+ "\\([^ \t\r\n()#\"\\\\]\\|\\\\.\\)\\([^ \t\r\n()#\\\\]\\|\\\\.\\)*")
+(defconst cmake-regex-token (concat "\\(" cmake-regex-comment
+ "\\|" cmake-regex-paren-left
+ "\\|" cmake-regex-paren-right
+ "\\|" cmake-regex-argument-unquoted
+ "\\|" cmake-regex-argument-quoted
+ "\\)"))
+(defconst cmake-regex-indented (concat "^\\("
+ cmake-regex-token
+ "\\|" "[ \t\r\n]"
+ "\\)*"))
+(defconst cmake-regex-block-open
+ "^\\(if\\|macro\\|foreach\\|else\\|elseif\\|while\\|function\\)$")
+(defconst cmake-regex-block-close
+ "^[ \t]*\\(endif\\|endforeach\\|endmacro\\|else\\|elseif\\|endwhile\\|endfunction\\)[ \t]*(")
+
+;------------------------------------------------------------------------------
+
+;;
+;; Helper functions for line indentation function.
+;;
+(defun cmake-line-starts-inside-string ()
+ "Determine whether the beginning of the current line is in a string."
+ (if (save-excursion
+ (beginning-of-line)
+ (let ((parse-end (point)))
+ (beginning-of-buffer)
+ (nth 3 (parse-partial-sexp (point) parse-end))
+ )
+ )
+ t
+ nil
+ )
+ )
+
+(defun cmake-find-last-indented-line ()
+ "Move to the beginning of the last line that has meaningful indentation."
+ (let ((point-start (point))
+ region)
+ (forward-line -1)
+ (setq region (buffer-substring-no-properties (point) point-start))
+ (while (and (not (bobp))
+ (or (looking-at cmake-regex-blank)
+ (cmake-line-starts-inside-string)
+ (not (and (string-match cmake-regex-indented region)
+ (= (length region) (match-end 0))))))
+ (forward-line -1)
+ (setq region (buffer-substring-no-properties (point) point-start))
+ )
+ )
+ )
+
+;------------------------------------------------------------------------------
+
+;;
+;; Line indentation function.
+;;
+(defun cmake-indent ()
+ "Indent current line as CMAKE code."
+ (interactive)
+ (if (cmake-line-starts-inside-string)
+ ()
+ (if (bobp)
+ (cmake-indent-line-to 0)
+ (let (cur-indent)
+
+ (save-excursion
+ (beginning-of-line)
+
+ (let ((point-start (point))
+ (case-fold-search t) ;; case-insensitive
+ token)
+
+ ; Search back for the last indented line.
+ (cmake-find-last-indented-line)
+
+ ; Start with the indentation on this line.
+ (setq cur-indent (current-indentation))
+
+ ; Search forward counting tokens that adjust indentation.
+ (while (re-search-forward cmake-regex-token point-start t)
+ (setq token (match-string 0))
+ (if (string-match (concat "^" cmake-regex-paren-left "$") token)
+ (setq cur-indent (+ cur-indent cmake-tab-width))
+ )
+ (if (string-match (concat "^" cmake-regex-paren-right "$") token)
+ (setq cur-indent (- cur-indent cmake-tab-width))
+ )
+ (if (and
+ (string-match cmake-regex-block-open token)
+ (looking-at (concat "[ \t]*" cmake-regex-paren-left))
+ )
+ (setq cur-indent (+ cur-indent cmake-tab-width))
+ )
+ )
+ (goto-char point-start)
+
+ ; If this is the end of a block, decrease indentation.
+ (if (looking-at cmake-regex-block-close)
+ (setq cur-indent (- cur-indent cmake-tab-width))
+ )
+ )
+ )
+
+ ; Indent this line by the amount selected.
+ (if (< cur-indent 0)
+ (cmake-indent-line-to 0)
+ (cmake-indent-line-to cur-indent)
+ )
+ )
+ )
+ )
+ )
+
+(defun cmake-point-in-indendation ()
+ (string-match "^[ \\t]*$" (buffer-substring (point-at-bol) (point))))
+
+(defun cmake-indent-line-to (column)
+ "Indent the current line to COLUMN.
+If point is within the existing indentation it is moved to the end of
+the indentation. Otherwise it retains the same position on the line"
+ (if (cmake-point-in-indendation)
+ (indent-line-to column)
+ (save-excursion (indent-line-to column))))
+
+;------------------------------------------------------------------------------
+
+;;
+;; Helper functions for buffer
+;;
+(defun unscreamify-cmake-buffer ()
+ "Convert all CMake commands to lowercase in buffer."
+ (interactive)
+ (setq save-point (point))
+ (goto-char (point-min))
+ (while (re-search-forward "^\\([ \t]*\\)\\(\\w+\\)\\([ \t]*(\\)" nil t)
+ (replace-match
+ (concat
+ (match-string 1)
+ (downcase (match-string 2))
+ (match-string 3))
+ t))
+ (goto-char save-point)
+ )
+
+;------------------------------------------------------------------------------
+
+;;
+;; Keyword highlighting regex-to-face map.
+;;
+(defconst cmake-font-lock-keywords
+ (list '("^[ \t]*\\(\\w+\\)[ \t]*(" 1 font-lock-function-name-face))
+ "Highlighting expressions for CMAKE mode."
+ )
+
+;------------------------------------------------------------------------------
+
+;;
+;; Syntax table for this mode. Initialize to nil so that it is
+;; regenerated when the cmake-mode function is called.
+;;
+(defvar cmake-mode-syntax-table nil "Syntax table for cmake-mode.")
+(setq cmake-mode-syntax-table nil)
+
+;;
+;; User hook entry point.
+;;
+(defvar cmake-mode-hook nil)
+
+;;
+;; Indentation increment.
+;;
+(defvar cmake-tab-width 2)
+
+;;
+;; Keymap.
+;;
+(defvar cmake-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map "\C-ch" 'cmake-help-command)
+ (define-key map "\C-cl" 'cmake-help-list-commands)
+ (define-key map "\C-cu" 'unscreamify-cmake-buffer)
+ map)
+ "Keymap used in cmake-mode buffers.")
+
+;------------------------------------------------------------------------------
+
+;;
+;; CMake mode startup function.
+;;
+(defun cmake-mode ()
+ "Major mode for editing CMake listfiles.
+
+\\{cmake-mode-map}"
+ (interactive)
+ (kill-all-local-variables)
+ (setq major-mode 'cmake-mode)
+ (setq mode-name "CMAKE")
+
+ ; Create the syntax table
+ (setq cmake-mode-syntax-table (make-syntax-table))
+ (set-syntax-table cmake-mode-syntax-table)
+ (modify-syntax-entry ?_ "w" cmake-mode-syntax-table)
+ (modify-syntax-entry ?\( "()" cmake-mode-syntax-table)
+ (modify-syntax-entry ?\) ")(" cmake-mode-syntax-table)
+ (modify-syntax-entry ?# "<" cmake-mode-syntax-table)
+ (modify-syntax-entry ?\n ">" cmake-mode-syntax-table)
+
+ ; Setup font-lock mode.
+ (make-local-variable 'font-lock-defaults)
+ (setq font-lock-defaults '(cmake-font-lock-keywords))
+
+ ; Setup indentation function.
+ (make-local-variable 'indent-line-function)
+ (setq indent-line-function 'cmake-indent)
+
+ ; Setup comment syntax.
+ (make-local-variable 'comment-start)
+ (setq comment-start "#")
+
+ ; Setup keymap.
+ (use-local-map cmake-mode-map)
+
+ ; Run user hooks.
+ (run-hooks 'cmake-mode-hook))
+
+; Help mode starts here
+
+
+(defun cmake-command-run (type &optional topic)
+ "Runs the command cmake with the arguments specified. The
+optional argument topic will be appended to the argument list."
+ (interactive "s")
+ (let* ((bufname (concat "*CMake" type (if topic "-") topic "*"))
+ (buffer (get-buffer bufname))
+ )
+ (if buffer
+ (display-buffer buffer 'not-this-window)
+ ;; Buffer doesn't exist. Create it and fill it
+ (setq buffer (generate-new-buffer bufname))
+ (setq command (concat cmake-mode-cmake-executable " " type " " topic))
+ (message "Running %s" command)
+ ;; We don't want the contents of the shell-command running to the
+ ;; minibuffer, so turn it off. A value of nil means don't automatically
+ ;; resize mini-windows.
+ (setq resize-mini-windows-save resize-mini-windows)
+ (setq resize-mini-windows nil)
+ (shell-command command buffer)
+ ;; Save the original window, so that we can come back to it later.
+ ;; save-excursion doesn't seem to work for this.
+ (setq window (selected-window))
+ ;; We need to select it so that we can apply special modes to it
+ (select-window (display-buffer buffer 'not-this-window))
+ (cmake-mode)
+ (toggle-read-only t)
+ ;; Restore the original window
+ (select-window window)
+ (setq resize-mini-windows resize-mini-windows-save)
+ )
+ )
+ )
+
+(defun cmake-help-list-commands ()
+ "Prints out a list of the cmake commands."
+ (interactive)
+ (cmake-command-run "--help-command-list")
+ )
+
+(defvar cmake-help-command-history nil "Topic read history.")
+
+(require 'thingatpt)
+(defun cmake-get-topic (type)
+ "Gets the topic from the minibuffer input. The default is the word the cursor is on."
+ (interactive)
+ (let* ((default-entry (word-at-point))
+ (input (read-string
+ (format "CMake %s (default %s): " type default-entry) ; prompt
+ nil ; initial input
+ 'cmake-help-command-history ; command history
+ default-entry ; default-value
+ )))
+ (if (string= input "")
+ (error "No argument given")
+ input))
+ )
+
+
+(defun cmake-help-command ()
+ "Prints out the help message corresponding to the command the cursor is on."
+ (interactive)
+ (setq command (cmake-get-topic "command"))
+ (cmake-command-run "--help-command" (downcase command))
+ )
+
+
+; This file provides cmake-mode.
+(provide 'cmake-mode)
+
+;;; cmake-mode.el ends here
diff --git a/Auxiliary/cmake-syntax.vim b/Auxiliary/cmake-syntax.vim
new file mode 100644
index 0000000..80395ab
--- /dev/null
+++ b/Auxiliary/cmake-syntax.vim
@@ -0,0 +1,89 @@
+" =============================================================================
+"
+" Program: CMake - Cross-Platform Makefile Generator
+" Module: $RCSfile$
+" Language: VIM
+" Date: $Date$
+" Version: $Revision$
+"
+" =============================================================================
+
+" Vim syntax file
+" Language: CMake
+" Author: Andy Cedilnik <andy.cedilnik@kitware.com>
+" Maintainer: Karthik Krishnan <karthik.krishnan@kitware.com>
+" Last Change: $Date$
+" Version: $Revision$
+"
+" Licence: The CMake license applies to this file. See
+" http://www.cmake.org/HTML/Copyright.html
+" This implies that distribution with Vim is allowed
+
+" For version 5.x: Clear all syntax items
+" For version 6.x: Quit when a syntax file was already loaded
+if version < 600
+ syntax clear
+elseif exists("b:current_syntax")
+ finish
+endif
+
+syn case ignore
+syn match cmakeEscaped /\(\\\\\|\\"\|\\n\|\\t\)/ contained
+syn region cmakeComment start="#" end="$" contains=cmakeTodo
+syn region cmakeRegistry start=/\[/ end=/]/
+ \ contained oneline contains=CONTAINED,cmakeTodo,cmakeEscaped
+syn region cmakeVariableValue start=/\${/ end=/}/
+ \ contained oneline contains=CONTAINED,cmakeTodo
+syn region cmakeEnvironment start=/\$ENV{/ end=/}/
+ \ contained oneline contains=CONTAINED,cmakeTodo
+syn region cmakeString start=/"/ end=/"/
+ \ contains=CONTAINED,cmakeTodo,cmakeOperators
+syn region cmakeArguments start=/(/ end=/)/
+ \ contains=ALLBUT,cmakeArguments,cmakeTodo
+syn keyword cmakeSystemVariables
+ \ WIN32 UNIX APPLE CYGWIN BORLAND MINGW MSVC MSVC_IDE MSVC60 MSVC70 MSVC71 MSVC80 MSVC90
+syn keyword cmakeOperators
+ \ ABSOLUTE AND BOOL CACHE COMMAND DEFINED DOC EQUAL EXISTS EXT FALSE GREATER INTERNAL LESS MATCHES NAME NAMES NAME_WE NOT OFF ON OR PATH PATHS PROGRAM STREQUAL STRGREATER STRING STRLESS TRUE
+ \ contained
+syn keyword cmakeDeprecated ABSTRACT_FILES BUILD_NAME SOURCE_FILES SOURCE_FILES_REMOVE VTK_MAKE_INSTANTIATOR VTK_WRAP_JAVA VTK_WRAP_PYTHON VTK_WRAP_TCL WRAP_EXCLUDE_FILES
+ \ nextgroup=cmakeArguments
+
+" The keywords are generated as: cmake --help-command-list | tr "\n" " "
+syn keyword cmakeStatement
+ \ ADD_CUSTOM_COMMAND ADD_CUSTOM_TARGET ADD_DEFINITIONS ADD_DEPENDENCIES ADD_EXECUTABLE ADD_LIBRARY ADD_SUBDIRECTORY ADD_TEST AUX_SOURCE_DIRECTORY BUILD_COMMAND BUILD_NAME CMAKE_MINIMUM_REQUIRED CONFIGURE_FILE CREATE_TEST_SOURCELIST ELSE ELSEIF ENABLE_LANGUAGE ENABLE_TESTING ENDFOREACH ENDFUNCTION ENDIF ENDMACRO ENDWHILE EXEC_PROGRAM EXECUTE_PROCESS EXPORT_LIBRARY_DEPENDENCIES FILE FIND_FILE FIND_LIBRARY FIND_PACKAGE FIND_PATH FIND_PROGRAM FLTK_WRAP_UI FOREACH FUNCTION GET_CMAKE_PROPERTY GET_DIRECTORY_PROPERTY GET_FILENAME_COMPONENT GET_SOURCE_FILE_PROPERTY GET_TARGET_PROPERTY GET_TEST_PROPERTY IF INCLUDE INCLUDE_DIRECTORIES INCLUDE_EXTERNAL_MSPROJECT INCLUDE_REGULAR_EXPRESSION INSTALL INSTALL_FILES INSTALL_PROGRAMS INSTALL_TARGETS LINK_DIRECTORIES LINK_LIBRARIES LIST LOAD_CACHE LOAD_COMMAND MACRO MAKE_DIRECTORY MARK_AS_ADVANCED MATH MESSAGE OPTION OUTPUT_REQUIRED_FILES PROJECT QT_WRAP_CPP QT_WRAP_UI REMOVE REMOVE_DEFINITIONS SEPARATE_ARGUMENTS SET SET_DIRECTORY_PROPERTIES SET_SOURCE_FILES_PROPERTIES SET_TARGET_PROPERTIES SET_TESTS_PROPERTIES SITE_NAME SOURCE_GROUP STRING SUBDIR_DEPENDS SUBDIRS TARGET_LINK_LIBRARIES TRY_COMPILE TRY_RUN UNSET USE_MANGLED_MESA UTILITY_SOURCE VARIABLE_REQUIRES VTK_MAKE_INSTANTIATOR VTK_WRAP_JAVA VTK_WRAP_PYTHON VTK_WRAP_TCL WHILE WRITE_FILE
+ \ nextgroup=cmakeArguments
+syn keyword cmakeTodo
+ \ TODO FIXME XXX
+ \ contained
+
+" Define the default highlighting.
+" For version 5.7 and earlier: only when not done already
+" For version 5.8 and later: only when an item doesn't have highlighting yet
+if version >= 508 || !exists("did_cmake_syntax_inits")
+ if version < 508
+ let did_cmake_syntax_inits = 1
+ command -nargs=+ HiLink hi link <args>
+ else
+ command -nargs=+ HiLink hi def link <args>
+ endif
+
+ HiLink cmakeStatement Statement
+ HiLink cmakeComment Comment
+ HiLink cmakeString String
+ HiLink cmakeVariableValue Type
+ HiLink cmakeRegistry Underlined
+ HiLink cmakeArguments Identifier
+ HiLink cmakeArgument Constant
+ HiLink cmakeEnvironment Special
+ HiLink cmakeOperators Operator
+ HiLink cmakeMacro PreProc
+ HiLink cmakeError Error
+ HiLink cmakeTodo TODO
+ HiLink cmakeEscaped Special
+
+ delcommand HiLink
+endif
+
+let b:current_syntax = "cmake"
+
+"EOF"