Skip to content

Make working with cmake *alot* more convenient #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Mar 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fa134d5
Add initial vader test
Squareys Mar 22, 2017
cd0c4c2
Add .travis.yml for linux CI builds
Squareys Mar 20, 2017
2d2ff78
Add appveyor.yml config for windows CI builds
Squareys Apr 6, 2017
9d6a175
Add Travis and AppVeyor badges
Squareys Mar 21, 2017
7de17c9
Make code formatting consistent
Squareys Apr 6, 2017
40eefdf
Extract new function cmake_configure()
Squareys Apr 6, 2017
644a644
Extract and reuse s:find_build_dir()
Squareys Apr 6, 2017
8c15efa
Store build dir as absolute path
Squareys Apr 6, 2017
26f0463
Do not reconfigure project if already configured
Squareys Apr 6, 2017
90ef71c
Use echom(sg) instead of echo to store messages in message-history
Squareys Apr 6, 2017
fb2ee0c
Setting the generator requires clean build
Squareys Apr 6, 2017
506c005
Add documentation and force parameter to s:cmake_configure()
Squareys Apr 6, 2017
41fade5
Update the README.md
Squareys Apr 6, 2017
7f2c0c4
Issue error message if cmake executable was not found
Squareys Apr 6, 2017
d8261e8
Allow finding build/ in directory of current file
Squareys Apr 8, 2017
cfa3b92
Do not expand path if not found
Squareys Apr 8, 2017
22e1787
Suppress "Press ENTER or type command to continue" prompts
Squareys Apr 8, 2017
8e27bf3
Reorder cmake arguments
Squareys Apr 8, 2017
3182afb
Add option to export compile commands for YCM
Squareys Apr 8, 2017
d2eb207
Update vim documentation
Squareys Apr 8, 2017
f0e126f
Never implicitly delete existing cmake config
Squareys Apr 8, 2017
06ff54d
Add option to symlink compilation database for YouCompleteMe
Squareys Apr 8, 2017
ff18ad0
Suppress "--- More ---" prompts
Squareys Apr 9, 2017
ab2c44a
Ensure every test runs on a clean build directory
Squareys Apr 9, 2017
e33b7f1
Fix build folder being found in path rather than cwd or path of buffer
Squareys Apr 9, 2017
ad618b4
Make build_dir variable buffer local
Squareys Apr 9, 2017
9269c7d
Update README.md
Squareys Apr 9, 2017
a14c1ad
Update vim documentation
Squareys Apr 9, 2017
5171f87
Fix some quirks with build dir finding especially on Travis CI
Squareys Apr 9, 2017
692dc06
Merge branch 'master' into changes-for-pullrequest
vhdirk Mar 30, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test/test project/build/
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
language: vim

addons:
apt:
sources:
- ubuntu-toolchain-r-test
- kubuntu-backports
packages:
- g++-4.7
- cmake

before_script: |
git clone https://github.com/junegunn/vader.vim.git

script: |
vim -Nu 'test/.vimrc' -c 'Vader! test/cmake.vader'
45 changes: 35 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# vim-cmake
[![Travis (Linux)](https://travis-ci.org/Squareys/vim-cmake.svg?branch=master)](https://travis-ci.org/Squareys/vim-cmake)
[![AppVeyor (Windows)](https://ci.appveyor.com/api/projects/status/8x1tk0wbu4564m43?svg=true)](https://ci.appveyor.com/project/Squareys/vim-cmake)

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

I got tired of navitating to the build directory each time, and I also
disliked setting makeprg manually each time. This plugin does just that.
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.

## Usage

Expand All @@ -12,46 +14,69 @@ disliked setting makeprg manually each time. This plugin does just that.
* `:CMake` searches 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
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](https://github.com/skywind3000/asyncrun.vim)
installed, it will be used automatically and you will be able to check the
result of the cmake command in the quickfix as well.

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

* `: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.

### Variables

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

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

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

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

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

* `g:cmake_project_generator` same as `-G`. Changes will have no effect until you run :CMakeClean and then :CMake.

* `g:cmake_export_compile_commands` same as `-DCMAKE_EXPORT_COMPILE_COMMANDS`.

* `g:cmake_ycm_symlinks` create symlinks to the generated compilation database for use with [YouCompleteMe](https://github.com/Valloric/YouCompleteMe/).

* `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.


## Installation

If you don't have a preferred installation method, I recommend
installing [pathogen.vim](https://github.com/tpope/vim-pathogen), and
then simply copy and paste:

### Vim-pathogen

With [pathogen.vim](https://github.com/tpope/vim-pathogen) 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
`:help cmake`.

### Vundle

With [Vundle.vim](https://github.com/VundleVim/Vundle.vim) simply add this repository to your plugins list:

Plugin 'vhdirk/vim-cmake'

## Acknowledgements

* Thanks to [Tim Pope](http://tpo.pe/), his plugins are really awesome.
* Thanks to @SteveDeFacto for extending this with more fine grained control.

* 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.
* 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.

## License

Expand Down
10 changes: 10 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
os: Visual Studio 2015

install:
- cinst vim
- cinst cmake
- set PATH=%PATH%;C:\Program Files\CMake\bin
- git clone https://github.com/junegunn/vader.vim

build_script:
- vim -Nu test/.vimrc -c 'Vader! test/cmake.vader' --not-a-term
40 changes: 31 additions & 9 deletions doc/cmake.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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


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

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

: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.

VARIABLES *cmake-variables*

g:cmake_install_prefix same as -DCMAKE_INSTALL_PREFIX

g:cmake_build_type same as -DCMAKE_BUILD_TYPE

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

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

g:cmake_build_shared_libs same as -DBUILD_SHARED_LIBS

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

g:cmake_project_generator set project generator
g:cmake_project_generator set project generator, however, this will have
no effect until you run :CMakeClean and :CMake.

g:cmake_usr_args custom user arguments. Ex: 'let g:cmake_usr_args="-DDEBUG=YES"'

b:build_dir 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.

OPTIONS *cmake-options*

g:cmake_export_compile_commands same as -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, useful for
exporting a compilation database to be used with YCM
(https://github.com/Valloric/YouCompleteMe#c-family-semantic-completion)
CMake only supports this flag with Ninja and Makefile generators.

g:cmake_ycm_symlinks create a symlink to the compile_commands.json file in the
root of the project (build/..) if the file is found.

Loading