# Is there a way to check when any cmake task has finished purely from the filesystem/build directory?

**URL:** https://discourse.cmake.org/t/is-there-a-way-to-check-when-any-cmake-task-has-finished-purely-from-the-filesystem-build-directory/8271
**Category:** Development
**Created:** [June 6, 2023, 7:54pm UTC](https://discourse.cmake.org/t/is-there-a-way-to-check-when-any-cmake-task-has-finished-purely-from-the-filesystem-build-directory/8271 "2023-06-06T19:54:29Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![J\_Rohit](https://discourse.cmake.org/user_avatar/discourse.cmake.org/j_rohit/32/3231_2.png) [@J\_Rohit](https://discourse.cmake.org/u/J_Rohit)
#### Post date: [June 6, 2023, 7:54pm UTC](https://discourse.cmake.org/t/is-there-a-way-to-check-when-any-cmake-task-has-finished-purely-from-the-filesystem-build-directory/8271/1 "2023-06-06T19:54:29Z")

</div>

If I am running a cmake task, let’s say `CMakeConfigure`, (and I know that I am running configure in the main thread), Is there a way for another thread to check if this configure step is completed just by looking at the _Filesystem/build directory_ while not having any communication with the main thread on the status of first cmake task/command (if the command is complete or exited)?

(Like say read the file outputs in the `CMakeCache.txt` or `codemodel targets` per target or something and check some file for an `exit code` and a `timestamp`…?)

**Reason for this** :  
I want to chain commands one after another, like Clean Rebuild, which cleans, generates and builds the project. The way I intend to do this is by sending the entire string of commands to a terminal (with the enter or return key) and when the command finishes, we launch the next task only on success of the previous.

* * *

**Exact Reference** :

> <https://github.com/Civitasv/cmake-tools.nvim/issues/60>
>
> Currently, I use these codes to check if there is a process is finished, which i…s need to chain callback.
> 
> https://github.com/Civitasv/cmake-tools.nvim/blob/3e5f768977a7825e70335feff2cfac56e54ac33b/lua/cmake-tools/terminal.lua#LL542C1-L560C6
> 
> But this will block neovim instance, we should find a non-blocking or async way to check this.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [June 7, 2023, 1:56pm UTC](https://discourse.cmake.org/t/is-there-a-way-to-check-when-any-cmake-task-has-finished-purely-from-the-filesystem-build-directory/8271/2 "2023-06-07T13:56:44Z")

</div>

You can check the generator-specific file that is expected to exist. `build.ninja`, `Makefile`, etc. You need to know the generator and IDE generators (I believe) have the top-level project name in their “main” expected file.

The other thing to do would be to have a command sequence like:

```sh
rm -f cmake-success cmake-failure
cmake … && touch cmake-success || touch cmake-failure

```

and watch for those files.

---

<div class="post-metadata">

### Author: ![J\_Rohit](https://discourse.cmake.org/user_avatar/discourse.cmake.org/j_rohit/32/3231_2.png) [@J\_Rohit](https://discourse.cmake.org/u/J_Rohit)
#### Post date: [June 8, 2023, 2:10am UTC](https://discourse.cmake.org/t/is-there-a-way-to-check-when-any-cmake-task-has-finished-purely-from-the-filesystem-build-directory/8271/3 "2023-06-08T02:10:50Z")

</div>

Thanks for the reply!  
Actually chaining commands is what I didn’t want to do… Or make is toolchain specific.

Is there something more pure CMakeSpecific? Like a file whose timestamp is updated each and every time we run any cmake command?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [June 8, 2023, 4:09am UTC](https://discourse.cmake.org/t/is-there-a-way-to-check-when-any-cmake-task-has-finished-purely-from-the-filesystem-build-directory/8271/4 "2023-06-08T04:09:02Z")

</div>

There might be, but I don’t think there’s any stability guarantee there.

Though there is one thing that might work: the [CMake File API](https://cmake.org/cmake/help/latest/manual/cmake-file-api.7.html). You can drop some dummy query and when the response is updated, CMake is “done enough”. I don’t know if there’s a guaranteed order between it and the build files being ready. Might be worth experimenting with at least.

---

<div class="post-metadata">

### Author: ![J\_Rohit](https://discourse.cmake.org/user_avatar/discourse.cmake.org/j_rohit/32/3231_2.png) [@J\_Rohit](https://discourse.cmake.org/u/J_Rohit)
#### Post date: [June 9, 2023, 4:54am UTC](https://discourse.cmake.org/t/is-there-a-way-to-check-when-any-cmake-task-has-finished-purely-from-the-filesystem-build-directory/8271/5 "2023-06-09T04:54:06Z")

</div>

Thanks for the suggestion!
