vim-cmake is a Vim plugin to make working with CMake a little nicer.
I got tired of navigating to the build directory each time, and I also disliked setting makeprg manually each time. This plugin does just that.
:CMakesearches for the closest directory named build in an upwards search, and whenever one is found, it runs the cmake command there, assuming the CMakeLists.txt file is just one directory above. Any arguments given to :CMake will be directly passed on to the cmake command. It also sets the working directory of the make command, so you can just use quickfix as with a normal Makefile project. If you have the AsyncRun plugin installed, it will be used automatically and you will be able to check the result of the cmake command in the quickfix as well.
:CMakeCleandeletes all files in the build directory. You can think of this as a CMake version of make clean.
:CMakeFindBuildDirresets the build directory path set for the current buffer and then tries to find a new one. Useful if it previously found a wrong path to then reset it after a new build folder has been created for example.
-DCMAKE_CXX_COMPILER. Changes will have no effect until you run :CMakeClean and then :CMake.
-DCMAKE_C_COMPILER. Changes will have no effect until you run :CMakeClean and then :CMake.
-G. Changes will have no effect until you run :CMakeClean and then :CMake.
g:cmake_ycm_symlinkscreate symlinks to the generated compilation database for use with YouCompleteMe.
b:build_diris the path to the cmake build directory for the current buffer. This variable is set with the first :CMake or :CMakeFindBuildDir call. Once found, it will not be searched for again unless you call :CMakeFindBuildDir. If automatic finding is not sufficient you can set this variable manually to the build dir of your choice.
With pathogen.vim simply copy and paste:
cd ~/.vim/bundle git clone git://github.com/vhdirk/vim-cmake.git
Once help tags have been generated, you can view the manual with
With Vundle.vim simply add this repository to your plugins list:
- Thanks to Tim Pope, his plugins are really awesome.
- Thanks to Junegunn Choi, for vader.vim, which is the testing framework used for this plugin.
- Also thanks to
- @SteveDeFacto for extending this with more fine grained control.
- @snikulov for enhancing makeprg.
- @dapicester for allowing specifying targets.
- @thomasgubler for the build dir option.
- @antmd for fixing a bug with handing of spaces in directory names.
- @jmirabel for fixing concatenation of cmake arguments.
- @T4ng10r for the project generator option.
- @Squareys for a small overhaul of the project, the initial test and travis setup.
Copyright (c) Dirk Van Haerenborgh, @SteveDeFacto. Distributed under the same terms as Vim itself.