# Good way of running custom commands serially

**URL:** https://discourse.cmake.org/t/good-way-of-running-custom-commands-serially/8412
**Category:** Code
**Created:** [June 27, 2023, 1:25am UTC](https://discourse.cmake.org/t/good-way-of-running-custom-commands-serially/8412 "2023-06-27T01:25:20Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![AnthonyD973](https://discourse.cmake.org/user_avatar/discourse.cmake.org/anthonyd973/32/3130_2.png) [@AnthonyD973](https://discourse.cmake.org/u/AnthonyD973)
#### Post date: [July 1, 2023, 9:44pm UTC](https://discourse.cmake.org/t/good-way-of-running-custom-commands-serially/8412/7 "2023-07-01T21:44:44Z")

</div>

Thanks for the help! From all the replies, I think running the command as part of a file-locking mechanism (like `flock`) would be the only viable solution. Platform compatibility is likely to be an issue (not sure if a readily-available equivalent would exist on Windows), but at least there _is_ a solution.

> [@ben.boeckel](#):
>
> However, I would caution against such a target being on in non-developer builds as `clang-format` is not stable over time

Letting myself get sidetracked here: yes, for example, I’ve seen [this post](https://discourse.cmake.org/t/clang-format-integration/3358/6) you’ve made about this specific point. In fact, [that’s exactly why my CMake module adds support for `git-clang-format`](https://github.com/adentinger/AdeClangFormat/blob/f04b87a8b9f33ff0e3436e45d676a5de4f55c7c8/doc/git-clang-format.md), rather than only plain `clang-format`. I plan to use to introduce this to an existing codebase that isn’t formatted properly, and using normal `clang-format` would require destroying version control history, even if we put the format checks only on the CI. Although, when using `git-clang-format` in production, I’m not sure whether automatic fixes might introduce bugs in the code or not, with the whole “consider only the modified lines” thing. I would guess not, but `git-clang-format` doesn’t seem too widely used so I wouldn’t trust it that easily.

This issue here is that, unlike normal `clang-format`, `git-clang-format` relies on `git`, which breaks when multiple processes are run simultaneously.

---

_[View the full topic](https://discourse.cmake.org/t/good-way-of-running-custom-commands-serially/8412)._
