ExternalProject: Updating an external project doesn't rebuild dependent targets
We have a project where we manage our thirdparty libraries as CMake external projects from tarball sources.
This works fine, but if we update any thirdparty library the targets that depend on that library will not always get rebuild which can cause linker errors if the new version of the thirdparty library is not ABI compatible with the previous version.
As far as I can tell, this is caused by CMake extracting the timestamps from the archives which will almost always be older than the binaries that was already build causing Ninja/Make etc. to consider those up to date. The only workaround is to clean and rebuild the entire project which is a bit unfortunate.
I've looked a bit into the CMake sources and I think it should indeed be possible to extend the ExternalProject_add command with an option to not extract the timestamps from the files in the archive. This should most likely be added to the file(ARCHIVE...)
command (something like EXTRACT_MTIME default to TRUE).
I wouldn't mind trying to write the code to achieve this and submit a MR if this has any interest?
The tricky part would be to write a reliable test since anything involving time is always a bit tricky, but I think I could figure something out although it might involve adding a new file()
command, something like file(STAT...)
for accessing file attributes from CMake scripts.
I could very well be completely wrong and just doing something wrong since I find it a bit surprising that it doesn't seem like anyone else is having this issue, in which I would very much like to know how to handle it.
Otherwise please let me know if this would be a feature that you would like CMake to support.
Thanks a lot.