cdelledonne / vim-cmake

Vim/Neovim plugin for working with CMake projects
MIT License
259 stars 21 forks source link

How to auto run CMakeGenerate before CMakeBuild? #77

Closed TSUHA0 closed 1 year ago

TSUHA0 commented 1 year ago

Hi, i want to know how to auto run CMakeGenerate before CMakeBuild, I try to set:

augroup vim-cmake-group
    autocmd User CMakeBuildPre CMakeGenerate
augroup END

but it failed. image

cdelledonne commented 1 year ago

Hi, thanks for asking this.

Autocommands should be used to run synchronous command, i.e. command that block the execution until they complete. :CMakeGenerate is an asynchronous command, it starts a job in the background and it does not block execution.

At the moment, if there's a (asynchronous) :CMake command running, attempting to run another :CMake command will throw the error you're seeing. I could implement something to fix this, e.g. pipeline commands and run them when nothing else is running, but I'd have to think whether this is a good idea.

Anyway, is there a good reason why you want to run :CMakeGenerate before :CMakeBuild? In general it should not be necessary, see for instance When should I rerun cmake? - Stack Overflow

TSUHA0 commented 1 year ago

I am a beginner of cmake, the information you provided is very useful. As you said it is not necessary. Thanks for your reply.

cdelledonne commented 1 year ago

You're very welcome!