# install(FILES ...) to ignore install of files when file at DESTINATION is newer/has been modified

**URL:** <https://discourse.cmake.org/t/install-files-to-ignore-install-of-files-when-file-at-destination-is-newer-has-been-modified/5140>\
**Category:** Code\
**Tags:** os:linux, gen:makefiles\
**Created:** [March 1, 2022, 11:27am UTC](https://discourse.cmake.org/t/install-files-to-ignore-install-of-files-when-file-at-destination-is-newer-has-been-modified/5140 "2022-03-01T11:27:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Caointean](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/c/49beb7/32.png) [@Caointean](https://discourse.cmake.org/u/Caointean)\
**Post date:** [March 1, 2022, 11:27am UTC](https://discourse.cmake.org/t/install-files-to-ignore-install-of-files-when-file-at-destination-is-newer-has-been-modified/5140/1 "2022-03-01T11:27:15Z")

</div>

Hello !

I’m looking for a way to prevent the `install(FILES <myfile> DESTINATION <myfolder>)` to re-install `<myfile>` when the file at destination `<folder>/<myfile>` is newer than the source.

To put things into context:  
We install our runtime configuration files for debugging and tuning our science algorithms at the same time than our libs and executables. These files can be modified on the fly by the user to enable/disable some log outputs and change some constants, so we really only need them to be updated only if the original file in the project source tree is newer than the one at destination (for instance when a new mandatory parameter has been added) so we don’t overwrite the changes made by the user to the destination file in the meantime.  
As of this moment, every call to `make install` re-installs the source tree version, which is a bit frustrating.

---

<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:** [March 1, 2022, 1:25pm UTC](https://discourse.cmake.org/t/install-files-to-ignore-install-of-files-when-file-at-destination-is-newer-has-been-modified/5140/2 "2022-03-01T13:25:03Z")

</div>

`install()` checks for file contents, not “newer”. You’ll need custom `install(CODE)` to do this detection to avoid the installation.

---

<div class="post-metadata">

**Author:** ![Caointean](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/c/49beb7/32.png) [@Caointean](https://discourse.cmake.org/u/Caointean)\
**Post date:** [March 1, 2022, 1:35pm UTC](https://discourse.cmake.org/t/install-files-to-ignore-install-of-files-when-file-at-destination-is-newer-has-been-modified/5140/3 "2022-03-01T13:35:30Z")

</div>

Thanks for the reply ! I’ll have to check how the CODE install works then 🙂

---

<div class="post-metadata">

**Author:** ![Caointean](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/c/49beb7/32.png) [@Caointean](https://discourse.cmake.org/u/Caointean)\
**Post date:** [March 1, 2022, 1:50pm UTC](https://discourse.cmake.org/t/install-files-to-ignore-install-of-files-when-file-at-destination-is-newer-has-been-modified/5140/4 "2022-03-01T13:50:43Z")

</div>

I’m curious on how the content check is performed ?  
Because we’ve had this other case of a file that is not updated on install when the install directive is :

```auto
INSTALL(FILES "${CMAKE_SOURCE_DIR}/conf/${SOME_VAR}/some_file.txt" DESTINATION "${DELIVERY_NAME}/conf")

```

With `SOME_VAR` given as a cmake command line define `-DSOME_VAR=pattern`, and the some\_file being different for each possible pattern.

---

<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:** [March 1, 2022, 5:44pm UTC](https://discourse.cmake.org/t/install-files-to-ignore-install-of-files-when-file-at-destination-is-newer-has-been-modified/5140/5 "2022-03-01T17:44:39Z")

</div>

Hmm. Maybe there is some timestamp shortcircuit going on too? But any source is likely to be “newer” than any given install if `git` is used.
