vim-cmake plugin enables to make call to CMake without leave Vim. Install plugin with your plugin manager and call:
or map this commands to a key:
au filetype cpp nnoremap <silent> <leader>cm :CMake<CR>
If you are using YouCompleteMe you may consider to generate compilation database and link them your project root:
let g:cmake_export_compile_commands=1 let g:cmake_ycm_symlinks=1
or set build generator with:
let g:cmake_project_generator="Unix Makefiles"
To make build your meta-build generated by CMake, you can run:
The default make program is GNU make. If your project is large, you might consider using Ninja after set build generator according to it.
set makeprg=ninja\ -C\ build
Happy safe coding!!