# Custom Command Mutual exclusion

**URL:** https://discourse.cmake.org/t/custom-command-mutual-exclusion/14180
**Category:** Development
**Created:** [May 30, 2025, 9:23am UTC](https://discourse.cmake.org/t/custom-command-mutual-exclusion/14180 "2025-05-30T09:23:33Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Malte](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ce7236/32.png) [@Malte](https://discourse.cmake.org/u/Malte)
#### Post date: [May 30, 2025, 9:23am UTC](https://discourse.cmake.org/t/custom-command-mutual-exclusion/14180/1 "2025-05-30T09:23:33Z")

</div>

I use custom commands heavily to generate files. [According to the help this is racy, unless a custom\_target is wrapped around the generation step](https://cmake.org/cmake/help/latest/command/add_custom_command.html#example-generating-files-for-multiple-targets).  
Would it make sense to protect custom commands with the same logic which protects targets from being executed multiple times (at least if the custom command has OUTPUTs). Or are there reasons to keep this racy?
