Issues when updating dependency included by FetchContent (file timestamps, old files)
When using FetchContent, the downloaded project becomes part of the current project and normal dependency tracking using timestamps of the source files happens.
This creates the following problem:
- Download foo v1. Timestamps of the source files are e.g. 2020-01-01
- Build project. Timestamps of object files are e.g. 2022-01-01
- Update foo to v2. Timestamps of the source files are e.g. 2021-01-01
- Build project. foo is not rebuilt since the object files are still newer than the source files.
Note that this only happens for archives, since the timestamps in the archive are preserved. git always touches all changed files so this is not an issue for git checkouts.
One way to solve this would be to touch the files unpacked from the downloaded archive.
Another way would be to clean the source & binary folders before unpacking an archive.
Maybe the latter would be preferable, since otherwise old files might be left from the old version and possibly cause other issues.
I can't see a way to do either in CMake. But maybe there's another way to achieve proper dependencies that I'm currently not seeing. Any help is much appreciated.