Difference between revisions of "CMake Editors Support"

From KitwarePublic
Jump to navigationJump to search
Line 3: Line 3:
 
There are [[CMake]] syntax highlighting and indentation supports for many editors:
 
There are [[CMake]] syntax highlighting and indentation supports for many editors:
  
* '''Eclipse''' The [http://www.cthing.com/CMakeEd.asp CMakeEd] plugin for Eclipse provides syntax coloring and content assist for editing CMakeLists.txt and any file ending in a .cmake extension. It also integrates the CMake command reference documentation into the Eclipse Help system. This plugin does NOT do project management for you or generate CMake files for you. You are still responsible for this part. CMakeEd just makes writing the CMakeLists.txt files easier.
+
* '''Eclipse''' There are two plugins for Eclipse:
 +
** The [http://www.cthing.com/CMakeEd.asp CMakeEd] plugin for Eclipse provides syntax coloring and content assist for editing CMakeLists.txt and any file ending in a .cmake extension. It also integrates the CMake command reference documentation into the Eclipse Help system. This plugin does NOT do project management for you or generate CMake files for you. You are still responsible for this part. CMakeEd just makes writing the CMakeLists.txt files easier.
 +
** The [http://www.cmakebuilder.com/ CMakeBuilder] plugin provides a user friendly interface to easily manage CMake-based projects, with the following features: advanced parser, Advanced CMake outline, CMakeBuilder perspective, symbol table and environment inspector, CMake files editor with syntax highlighting, code assist, wizard-oriented project management, Project Nature CMakeBuilder for CDT projects, and incremental project builders.
  
 
* '''Emacs''' [http://www.cmake.org/CMakeDocs/cmake-mode.el combined syntax highlighting and indentation mode].  The current file in the repository doesn't behave very well if you try to run fill-paragrap (M-q) on comments.  This [[CMake Emacs mode patch for comment formatting|patched version]] written by Miguel A. Figueroa-Villanueva fixes it.  Hopefully the patch will make it into the tree someday. To enable it, add the following to your ''.emacs'' file:
 
* '''Emacs''' [http://www.cmake.org/CMakeDocs/cmake-mode.el combined syntax highlighting and indentation mode].  The current file in the repository doesn't behave very well if you try to run fill-paragrap (M-q) on comments.  This [[CMake Emacs mode patch for comment formatting|patched version]] written by Miguel A. Figueroa-Villanueva fixes it.  Hopefully the patch will make it into the tree someday. To enable it, add the following to your ''.emacs'' file:

Revision as of 07:56, 2 April 2008

CMake Editor Modes

There are CMake syntax highlighting and indentation supports for many editors:

  • Eclipse There are two plugins for Eclipse:
    • The CMakeEd plugin for Eclipse provides syntax coloring and content assist for editing CMakeLists.txt and any file ending in a .cmake extension. It also integrates the CMake command reference documentation into the Eclipse Help system. This plugin does NOT do project management for you or generate CMake files for you. You are still responsible for this part. CMakeEd just makes writing the CMakeLists.txt files easier.
    • The CMakeBuilder plugin provides a user friendly interface to easily manage CMake-based projects, with the following features: advanced parser, Advanced CMake outline, CMakeBuilder perspective, symbol table and environment inspector, CMake files editor with syntax highlighting, code assist, wizard-oriented project management, Project Nature CMakeBuilder for CDT projects, and incremental project builders.
  • Emacs combined syntax highlighting and indentation mode. The current file in the repository doesn't behave very well if you try to run fill-paragrap (M-q) on comments. This patched version written by Miguel A. Figueroa-Villanueva fixes it. Hopefully the patch will make it into the tree someday. To enable it, add the following to your .emacs file:
; Add cmake listfile names to the mode list.
(setq auto-mode-alist
	  (append
	   '(("CMakeLists\\.txt\\'" . cmake-mode))
	   '(("\\.cmake\\'" . cmake-mode))
	   auto-mode-alist))

(autoload 'cmake-mode "~/CMake/Docs/cmake-mode.el" t)
  • Enscript syntax highlighting rules. To enable it:
    1. copy cmake.st in the hl/ directory.
    2. add the following in the namerules section of the hl/enscript.st file:
  /CMakeLists\.txt/               cmake;
  /\.cmake.*$/                    cmake;
  /\.ctest.*$/                    cmake;
  • Kate, KWrite, KDevelop and all other KDE applications, which use the kate text-editing component support cmake syntax highlighting since KDE 3.4.
  • SciTE version 1.73 has CMake support. To enable the feature edit SciTEGlobal.Properties and remove the comment before the CMake lines.
  • TextMate is a wonderful text editor for OS X. CMake Bundle. This plugin adds syntax highlighting for CMake files.
  • VIM syntax highlighting and indentation mode. To enable indentation, copy indentation file to your .vim/indent directory, syntax highlighting file to your .vim/syntax directory and add the following to your .vimrc:
:autocmd BufRead,BufNewFile *.cmake,CMakeLists.txt,*.cmake.in runtime! indent/cmake.vim 
:autocmd BufRead,BufNewFile *.cmake,CMakeLists.txt,*.cmake.in setf cmake
:autocmd BufRead,BufNewFile *.ctest,*.ctest.in setf cmake

Creating New Editor Mode

The best way to start is to check the logic in existing ones. Make sure to enable indentation for files that match the following file names:

  • CMakeLists.txt
  • *.cmake
  • *.cmake.in
  • *.ctest
  • *.ctest.in