Skip to content

Commit f74124b

Browse files
authored
Merge pull request vhdirk#14 from Squareys/changes-for-pullrequest
Make working with cmake *alot* more convenient
2 parents d3f2313 + 0a78d18 commit f74124b

File tree

11 files changed

+302
-77
lines changed

11 files changed

+302
-77
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test/test project/build/

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
language: vim
2+
3+
addons:
4+
apt:
5+
sources:
6+
- ubuntu-toolchain-r-test
7+
- kubuntu-backports
8+
packages:
9+
- g++-4.7
10+
- cmake
11+
12+
before_script: |
13+
git clone https://github.com/junegunn/vader.vim.git
14+
15+
script: |
16+
vim -Nu 'test/.vimrc' -c 'Vader! test/cmake.vader'

README.md

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# vim-cmake
2+
[![Travis (Linux)](https://travis-ci.org/Squareys/vim-cmake.svg?branch=master)](https://travis-ci.org/Squareys/vim-cmake)
3+
[![AppVeyor (Windows)](https://ci.appveyor.com/api/projects/status/8x1tk0wbu4564m43?svg=true)](https://ci.appveyor.com/project/Squareys/vim-cmake)
24

35
vim-cmake is a Vim plugin to make working with CMake a little nicer.
46

5-
I got tired of navitating to the build directory each time, and I also
6-
disliked setting makeprg manually each time. This plugin does just that.
7+
I got tired of navigating to the build directory each time, and I also
8+
disliked setting makeprg manually each time. This plugin does just that.
79

810
## Usage
911

@@ -12,46 +14,69 @@ disliked setting makeprg manually each time. This plugin does just that.
1214
* `:CMake` searches for the closest directory named build in an upwards search,
1315
and whenever one is found, it runs the cmake command there, assuming the CMakeLists.txt
1416
file is just one directory above. Any arguments given to :CMake will be directly passed
15-
on to the cmake command. It also sets the working directory of the make command, so
17+
on to the cmake command. It also sets the working directory of the make command, so
1618
you can just use quickfix as with a normal Makefile project.
1719
If you have the [AsyncRun plugin](https://github.com/skywind3000/asyncrun.vim)
1820
installed, it will be used automatically and you will be able to check the
1921
result of the cmake command in the quickfix as well.
2022

2123
* `:CMakeClean` deletes all files in the build directory. You can think of this as a CMake version of make clean.
2224

25+
* `:CMakeFindBuildDir` resets 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.
26+
2327
### Variables
2428

2529
* `g:cmake_install_prefix` same as `-DCMAKE_INSTALL_PREFIX`
2630

2731
* `g:cmake_build_type` same as `-DCMAKE_BUILD_TYPE`
2832

29-
* `g:cmake_cxx_compiler` same as `-DCMAKE_CXX_COMPILER`. The build directory will be cleared the next time you run :CMake.
33+
* `g:cmake_cxx_compiler` same as `-DCMAKE_CXX_COMPILER`. Changes will have no effect until you run :CMakeClean and then :CMake.
3034

31-
* `g:cmake_c_compiler` same as `-DCMAKE_C_COMPILER`. The build directory will be cleared the next time you run :CMake.
35+
* `g:cmake_c_compiler` same as `-DCMAKE_C_COMPILER`. Changes will have no effect until you run :CMakeClean and then :CMake.
3236

3337
* `g:cmake_build_shared_libs` same as `-DBUILD_SHARED_LIBS`
3438

39+
* `g:cmake_project_generator` same as `-G`. Changes will have no effect until you run :CMakeClean and then :CMake.
40+
41+
* `g:cmake_export_compile_commands` same as `-DCMAKE_EXPORT_COMPILE_COMMANDS`.
42+
43+
* `g:cmake_ycm_symlinks` create symlinks to the generated compilation database for use with [YouCompleteMe](https://github.com/Valloric/YouCompleteMe/).
44+
45+
* `b:build_dir` is 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.
46+
3547

3648
## Installation
3749

38-
If you don't have a preferred installation method, I recommend
39-
installing [pathogen.vim](https://github.com/tpope/vim-pathogen), and
40-
then simply copy and paste:
50+
51+
### Vim-pathogen
52+
53+
With [pathogen.vim](https://github.com/tpope/vim-pathogen) simply copy and paste:
4154

4255
cd ~/.vim/bundle
4356
git clone git://github.com/vhdirk/vim-cmake.git
4457

4558
Once help tags have been generated, you can view the manual with
4659
`:help cmake`.
4760

61+
### Vundle
4862

63+
With [Vundle.vim](https://github.com/VundleVim/Vundle.vim) simply add this repository to your plugins list:
64+
65+
Plugin 'vhdirk/vim-cmake'
4966

5067
## Acknowledgements
5168

5269
* Thanks to [Tim Pope](http://tpo.pe/), his plugins are really awesome.
53-
* Thanks to @SteveDeFacto for extending this with more fine grained control.
54-
70+
* Thanks to [Junegunn Choi](https://junegunn.kr/), for [vader.vim](https://github.com/junegunn/vader.vim), which is the testing framework used for this plugin.
71+
* Also thanks to
72+
* @SteveDeFacto for extending this with more fine grained control.
73+
* @snikulov for enhancing makeprg.
74+
* @dapicester for allowing specifying targets.
75+
* @thomasgubler for the build dir option.
76+
* @antmd for fixing a bug with handing of spaces in directory names.
77+
* @jmirabel for fixing concatenation of cmake arguments.
78+
* @T4ng10r for the project generator option.
79+
* @Squareys for a small overhaul of the project, the initial test and travis setup.
5580

5681
## License
5782

appveyor.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
os: Visual Studio 2015
2+
3+
install:
4+
- cinst vim
5+
- cinst cmake
6+
- set PATH=%PATH%;C:\Program Files\CMake\bin
7+
- git clone https://github.com/junegunn/vader.vim
8+
9+
build_script:
10+
- vim -Nu test/.vimrc -c 'Vader! test/cmake.vader' --not-a-term

doc/cmake.txt

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
Authors: Dirk Van Haerenborgh <http://vhdirk.github.com/>
44
Steven Batchelor <http://SteveDeFacto.github.com/>
5+
Jonathan Hale <http://github.com/Squareys/>
56
License: Same terms as Vim itself (see |license|)
67

78

@@ -19,27 +20,48 @@ COMMANDS *cmake-commands*
1920
Also modifies the :make command to build in
2021
that directory.
2122

22-
:CMakeClean deletes all files in the build directory. You can
23-
think of this as a CMake version of make clean.
23+
:CMakeClean deletes all files in the build directory. You can
24+
think of this as a CMake version of make clean.
25+
26+
:CMakeFindBuildDir resets the build directory path set for the current buffer
27+
and then tries to find a new one. Useful if it previously
28+
found a wrong path to then reset it after a new build folder
29+
has been created for example.
2430

2531
VARIABLES *cmake-variables*
2632

2733
g:cmake_install_prefix same as -DCMAKE_INSTALL_PREFIX
2834

2935
g:cmake_build_type same as -DCMAKE_BUILD_TYPE
3036

31-
g:cmake_cxx_compiler same as -DCMAKE_CXX_COMPILER, however, do note that
32-
the build directory will be cleared the next time you
33-
run :CMake.
37+
g:cmake_cxx_compiler same as -DCMAKE_CXX_COMPILER, however, this will have
38+
no effect until you run :CMakeClean and :CMake.
3439

35-
g:cmake_c_compiler same as -DCMAKE_C_COMPILER, however, do note that the
36-
build directory will be cleared the next time you
37-
run :CMake.
40+
g:cmake_c_compiler same as -DCMAKE_C_COMPILER, however, this will have
41+
no effect until you run :CMakeClean and :CMake.
3842

3943
g:cmake_build_shared_libs same as -DBUILD_SHARED_LIBS
4044

4145
g:cmake_build_dir set the cmake 'build' directory, default: 'build'
4246

43-
g:cmake_project_generator set project generator
47+
g:cmake_project_generator set project generator, however, this will have
48+
no effect until you run :CMakeClean and :CMake.
4449

4550
g:cmake_usr_args custom user arguments. Ex: 'let g:cmake_usr_args="-DDEBUG=YES"'
51+
52+
b:build_dir the path to the cmake build directory for the current buffer.
53+
This variable is set with the first :CMake or :CMakeFindBuildDir call.
54+
Once found, it will not be searched for again unless you call
55+
:CMakeFindBuildDir. If automatic finding is not sufficient you can set
56+
this variable manually to the build dir of your choice.
57+
58+
OPTIONS *cmake-options*
59+
60+
g:cmake_export_compile_commands same as -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, useful for
61+
exporting a compilation database to be used with YCM
62+
(https://github.com/Valloric/YouCompleteMe#c-family-semantic-completion)
63+
CMake only supports this flag with Ninja and Makefile generators.
64+
65+
g:cmake_ycm_symlinks create a symlink to the compile_commands.json file in the
66+
root of the project (build/..) if the file is found.
67+

0 commit comments

Comments
 (0)