# Add dependency to ZERO\_CHECK? \[SOLVED\]

**URL:** https://discourse.cmake.org/t/add-dependency-to-zero-check-solved/5957
**Category:** Code
**Created:** [June 28, 2022, 10:26pm UTC](https://discourse.cmake.org/t/add-dependency-to-zero-check-solved/5957 "2022-06-28T22:26:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![marco1475](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@marco1475](https://discourse.cmake.org/u/marco1475)
#### Post date: [June 28, 2022, 10:26pm UTC](https://discourse.cmake.org/t/add-dependency-to-zero-check-solved/5957/1 "2022-06-28T22:26:56Z")

</div>

For my project I need to create executables with different “branding” (e.g. exe file name, window title, etc.), some of which needs to be compiled in (i.e. not runtime editable).

Since the branding will be modified by non-programmers I set up a JSON file that gets passed to CMake as a command-line argument (-DBranding=“MyBrand.json”). In my CMakeLists.txt I read the JSON file and use its values to populate preprocessor definitions that then get used in C++ code.

The trouble is that any changes to the JSON do not get picked up by ZERO\_CHECK, the “let me re-run CMake for you, because CMake files changed” target.

Adding the JSON file to the executable target doesn’t help, because changes to the JSON file need to trigger a CMake re-run to update the preprocessor definitions. Re-compiling the target when the JSON changes is useless, because CMake didn’t change the preprocessor definitions.

Is it possible to add a file dependency to ZERO\_CHECK? Similarly to how it already checks whether CMakePresets.json was modified after its last run, I’d like it to check the timestamp of my JSON file …

---

<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: [June 28, 2022, 10:46pm UTC](https://discourse.cmake.org/t/add-dependency-to-zero-check-solved/5957/2 "2022-06-28T22:46:17Z")

</div>

The better solution is to use `add_custom_command` to read the JSON and write a header or something like that.

Failing that, you can add to [`CMAKE_CONFIGURE_DEPENDS`](https://cmake.org/cmake/help/latest/prop_dir/CMAKE_CONFIGURE_DEPENDS.html) to make CMake rerun when the file changes.

---

<div class="post-metadata">

### Author: ![marco1475](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@marco1475](https://discourse.cmake.org/u/marco1475)
#### Post date: [June 29, 2022, 1:06am UTC](https://discourse.cmake.org/t/add-dependency-to-zero-check-solved/5957/3 "2022-06-29T01:06:08Z")

</div>

Thank you for the `add_custom_command` idea, that might be a better approach.

Regardless, `CMAKE_CONFIGURE_DEPENDS` is exactly what I was looking for! Much appreciated!
