# How to add a \`DEPENDS\` onto \`execute\_process\`

**URL:** https://discourse.cmake.org/t/how-to-add-a-depends-onto-execute-process/6048
**Category:** Usage
**Created:** [July 11, 2022, 7:54pm UTC](https://discourse.cmake.org/t/how-to-add-a-depends-onto-execute-process/6048 "2022-07-11T19:54:16Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Barry\_Revzin](https://discourse.cmake.org/user_avatar/discourse.cmake.org/barry_revzin/32/1283_2.png) [@Barry\_Revzin](https://discourse.cmake.org/u/Barry_Revzin)
#### Post date: [July 11, 2022, 7:54pm UTC](https://discourse.cmake.org/t/how-to-add-a-depends-onto-execute-process/6048/1 "2022-07-11T19:54:16Z")

</div>

I have a build setup that involves doing something like:

```cmake
execute_process(
    COMMAND python do_some_stuff.py --output moar_build.cmake
    OUTPUT_FILE moar_build.cmake)
include(moar_build.cmake)

```

Basically, I have this complicated python script that sets up logic that generates a CMake file to then be included into the build.

I can’t make this an `add_custom_command` because I can’t then add `moar_build.cmake` into the build itself, since that doesn’t get run until the build stage, so this is too late.

But it appears that `execute_process` doesn’t have a `DEPENDS` like `add_custom_command` does, so if `do_some_stuff.py` changes, then it doesn’t get rerun (I would have to manually reconfigure).

Is there any other way to get something like this to work? That is, I need to run a program during the configuration phase of cmake in order to then include the generated cmake file as part of the build, but actually have changes to that program cause reconfiguration?

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [July 11, 2022, 8:48pm UTC](https://discourse.cmake.org/t/how-to-add-a-depends-onto-execute-process/6048/2 "2022-07-11T20:48:36Z")

</div>

Have a look at the [CMAKE\_CONFIGURE\_DEPENDS](https://cmake.org/cmake/help/latest/prop_dir/CMAKE_CONFIGURE_DEPENDS.html) directory property.

---

<div class="post-metadata">

### Author: ![Barry\_Revzin](https://discourse.cmake.org/user_avatar/discourse.cmake.org/barry_revzin/32/1283_2.png) [@Barry\_Revzin](https://discourse.cmake.org/u/Barry_Revzin)
#### Post date: [July 11, 2022, 9:47pm UTC](https://discourse.cmake.org/t/how-to-add-a-depends-onto-execute-process/6048/3 "2022-07-11T21:47:56Z")

</div>

Yeah that works. It’d be great if that link actually explained how to use the property, but ideally it’d be even better if `execute_process` just had this as a parameter (since I don’t want to rerun the whole configuration, I know I just need to rerun this one `execute_process`, so it’s a bit wasteful to do more work).

---

<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: [July 11, 2022, 10:23pm UTC](https://discourse.cmake.org/t/how-to-add-a-depends-onto-execute-process/6048/4 "2022-07-11T22:23:31Z")

</div>

> [@Barry\_Revzin](#):
>
> (since I don’t want to rerun the whole configuration, I know I just need to rerun this one `execute_process`, so it’s a bit wasteful to do more work).

CMake is not able to build up the state pre-`include`, do the include, then continue from there other than by executing from the top.
