# execute\_process() vs add\_custom\_command()

**URL:** https://discourse.cmake.org/t/execute-process-vs-add-custom-command/3286
**Category:** Code
**Created:** [May 10, 2021, 1:23pm UTC](https://discourse.cmake.org/t/execute-process-vs-add-custom-command/3286 "2021-05-10T13:23:57Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ymba9g8j9cjp0wloqf5y/32/1244_2.png) [@YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/u/YMba9g8j9CJp0wLoQf5y)
#### Post date: [May 10, 2021, 1:48pm UTC](https://discourse.cmake.org/t/execute-process-vs-add-custom-command/3286/3 "2021-05-10T13:48:03Z")

</div>

I really don’t like using execute\_process unless I have to. Because execute\_process is done during the **configure stage** of cmake. To me a very quick configure stage is really important. Adding too much logic to your configure step slows down iteration speed which is crucial for rapid development/testing. Also execute\_process tends to be slower on Windows ([Why is cmake on Linux so much faster than on Windows?](https://discourse.cmake.org/t/why-is-cmake-on-linux-so-much-faster-than-on-windows/1918)) depending on what you are doing.

I like using add\_custom\_command since it happens during the **build step** and can be parallelized. Even if your custom task is single threaded the build can still potentially be running other tasks and whatnot.

Overall my opinion is:  
1.) Make sure you really need to do this in the first place. Get another person’s opinion.  
2.) **Document** what you are doing. Make sure other people understand what your custom build task is doing.  
3.) Choose add\_custom\_command over execute\_process **if possible**

---

_[View the full topic](https://discourse.cmake.org/t/execute-process-vs-add-custom-command/3286)._
