# Method to force a rerun of cmake

**URL:** <https://discourse.cmake.org/t/method-to-force-a-rerun-of-cmake/4665>\
**Category:** Code\
**Created:** [December 14, 2021, 7:04pm UTC](https://discourse.cmake.org/t/method-to-force-a-rerun-of-cmake/4665 "2021-12-14T19:04:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![scottaronbloom](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/b4bc9f/32.png) [@scottaronbloom](https://discourse.cmake.org/u/scottaronbloom)\
**Post date:** [December 14, 2021, 7:04pm UTC](https://discourse.cmake.org/t/method-to-force-a-rerun-of-cmake/4665/1 "2021-12-14T19:04:26Z")

</div>

In the same manner that all CMakeLists.txt (and other) files cause an out of date mode for the cmake system itself, where if you modify one of the cmake files, cmake is automatically re-run. In visual studio this is part of the ZERO\_CHECK targets I believe

Is there anyway to have an arbitrary file do the same?

The issue is this. I have a version.h file, that is used in the application. I also use file( read …) to scrape the necessary parameters out of the file for the CPACK variables.

It works great, however, when I rev the version, I need to remember to re-run cmake, to update the CPACK variables.

I would like to automate this. Any suggestions?

---

<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:** [December 14, 2021, 7:11pm UTC](https://discourse.cmake.org/t/method-to-force-a-rerun-of-cmake/4665/2 "2021-12-14T19:11:29Z")

</div>

You can use the [`CMAKE_CONFIGURE_DEPENDS`](https://cmake.org/cmake/help/latest/prop_dir/CMAKE_CONFIGURE_DEPENDS.html) directory property to do this.

---

<div class="post-metadata">

**Author:** ![scottaronbloom](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/b4bc9f/32.png) [@scottaronbloom](https://discourse.cmake.org/u/scottaronbloom)\
**Post date:** [December 14, 2021, 7:13pm UTC](https://discourse.cmake.org/t/method-to-force-a-rerun-of-cmake/4665/3 "2021-12-14T19:13:16Z")

</div>

I have been looking for this variable for years!!! Thanks.

I had actually created a custom command to do this, but it always seemed like a hack.

---

<div class="post-metadata">

**Author:** ![scottaronbloom](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/b4bc9f/32.png) [@scottaronbloom](https://discourse.cmake.org/u/scottaronbloom)\
**Post date:** [December 15, 2021, 12:13am UTC](https://discourse.cmake.org/t/method-to-force-a-rerun-of-cmake/4665/4 "2021-12-15T00:13:24Z")

</div>

Thanks. I was able to get it working.
