# External project; cmake not re-building when source time stamp changes

**URL:** <https://discourse.cmake.org/t/external-project-cmake-not-re-building-when-source-time-stamp-changes/7499>\
**Category:** Code\
**Created:** [February 20, 2023, 9:43am UTC](https://discourse.cmake.org/t/external-project-cmake-not-re-building-when-source-time-stamp-changes/7499 "2023-02-20T09:43:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmak](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/c/eb8c5e/32.png) [@cmak](https://discourse.cmake.org/u/cmak)\
**Post date:** [February 20, 2023, 9:43am UTC](https://discourse.cmake.org/t/external-project-cmake-not-re-building-when-source-time-stamp-changes/7499/1 "2023-02-20T09:43:15Z")

</div>

I have an external project built by cmake (`ExternalProject_Add`), but cmake does not detect if any of the source files inside the external gets an updated time stamp. The only way seems to be to force it happening by setting `BUILD_ALWAYS TRUE`. Is that expected? The external is pulled in as a git submodule and the `SOURCE_DIR` is pointing that submodule.

---

<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:** [February 20, 2023, 2:20pm UTC](https://discourse.cmake.org/t/external-project-cmake-not-re-building-when-source-time-stamp-changes/7499/2 "2023-02-20T14:20:06Z")

</div>

External projects do not track every single file involved in the build as this is not possible in general. I suppose you could feed `file(GLOB)` output to `DEPENDS` for a custom step you inject into the default step graph in the meantime…

---

<div class="post-metadata">

**Author:** ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Post date:** [February 20, 2023, 8:47pm UTC](https://discourse.cmake.org/t/external-project-cmake-not-re-building-when-source-time-stamp-changes/7499/3 "2023-02-20T20:47:48Z")

</div>

`BUILD_ALWAYS TRUE` is the right thing to do here. Your scenario allows files to change under ExternalProject’s feet, with no details about the external project (meaning none of the arguments passed to `ExternalProject_Add()`) changing. You want the behavior where the build detects if a file change, which is what `BUILD_ALWAYS` is there to support.
