CMake Editors Support: Difference between revisions
JoseFonseca (talk | contribs) (Eclipse CDT tips) |
|||
Line 50: | Line 50: | ||
* *.ctest | * *.ctest | ||
* *.ctest.in | * *.ctest.in | ||
==Using CMake from Eclipse CDT== | |||
Eclipse CDT can interoperate with CMake by creating a "Standard Makefile" project, running CMake, and then having CDT to run make on the generated makefiles. Eclipse CDT works better if the build files are somewhere in project directory, either in the top-level directory, or a subdirectory (for example Build). | |||
The CDT Error Parser cannot handle error messages that span more than one line, which is the default gcc behavior. In order to | |||
force gcc to generate single line error messages with no line wrapping, add to your CMakeLists.txt: | |||
IF(CMAKE_COMPILER_IS_GNUCC) | |||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0") | |||
ENDIF(CMAKE_COMPILER_IS_GNUCC) | |||
IF(CMAKE_COMPILER_IS_GNUCXX) | |||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmessage-length=0") | |||
ENDIF(CMAKE_COMPILER_IS_GNUCXX) | |||
In order for the CDT discovery mechanism to catch the compiler options and definitions automatically from the | |||
build output, enable the "Enable build output info discovery" in the project properties and set the CMAKE_VERBOSE_MAKEFILE | |||
variable in your CMakeLists.txt. | |||
SET(CMAKE_VERBOSE_MAKEFILE ON) | |||
If you don't want to hard-code this behavior in CMakeLists.txt, you can achieve the same effect by | |||
telling CDT to invoke make as | |||
make VERBOSE=1 | |||
{{CMake/Template/Footer}} | {{CMake/Template/Footer}} |
Revision as of 08:12, 11 May 2007
CMake Editor Modes
There are CMake syntax highlighting and indentation supports for several editors:
- Emacs combined syntax highlighting and indentation mode. 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)
- 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
- Eclipse CMake Editor. Plug-in for the Eclipse IDE providing syntax coloring and content assist for editing CMakeLists.txt and any file ending in a .cmake extension. Integrates the CMake command reference documentation into the Eclipse Help system.
- Kate, KWrite, KDevelop and all other KDE applications, which use the kate text-editing component support cmake syntax highlighting. Currently you have to open the settings dialog and choose download (Settings -> Configure Kate -> Editor -> Highlighting -> Download) and there select CMake in the listbox. Then the cmake syntax highlighting definition file for kate will be downloaded and installed. From KDE 3.4 and later cmake syntax highlighting will come with standard KDE.
- UltraEdit (an approach) save the jpg as text: File:Wordfile.jpg
- Enscript syntax highlighting rules. To enable it:
- copy cmake.st in the hl/ directory.
- add the following in the namerules section of the hl/enscript.st file:
/CMakeLists\.txt/ cmake; /\.cmake.*$/ cmake; /\.ctest.*$/ cmake;
- SciTE version 1.73 has CMake support. To enable the feature edit SciTEGlobal.Properties and remove the comment before cmake lines.
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
Using CMake from Eclipse CDT
Eclipse CDT can interoperate with CMake by creating a "Standard Makefile" project, running CMake, and then having CDT to run make on the generated makefiles. Eclipse CDT works better if the build files are somewhere in project directory, either in the top-level directory, or a subdirectory (for example Build).
The CDT Error Parser cannot handle error messages that span more than one line, which is the default gcc behavior. In order to force gcc to generate single line error messages with no line wrapping, add to your CMakeLists.txt:
IF(CMAKE_COMPILER_IS_GNUCC) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0") ENDIF(CMAKE_COMPILER_IS_GNUCC) IF(CMAKE_COMPILER_IS_GNUCXX) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmessage-length=0") ENDIF(CMAKE_COMPILER_IS_GNUCXX)
In order for the CDT discovery mechanism to catch the compiler options and definitions automatically from the build output, enable the "Enable build output info discovery" in the project properties and set the CMAKE_VERBOSE_MAKEFILE variable in your CMakeLists.txt.
SET(CMAKE_VERBOSE_MAKEFILE ON)
If you don't want to hard-code this behavior in CMakeLists.txt, you can achieve the same effect by telling CDT to invoke make as
make VERBOSE=1