cmakebuildconfigurationtimeshift

CMake generates object files timed before their compilation occurred


I'm using CMake and GNU Make to build a C++ project of mine on some machine. Strangely, I find that sometimes, the dates of on executables and object files (.o) generated during a cmake --build are a while before I performed the build.

What could be the causes of such a situation? And - can one prevent this using some kind of CMake or GNU Make option? i.e. have artifacts dated to the moment of their creation.

Version info in case it matters: CMake 3.28.3, GNU Make 4.2.1, OS distro SLES 15 SP1. I can add more information, to an extent; ask in the comments if something more could be of use.


Solution

  • As @Tsyvarev speculated in a comment, the reason is neither CMake nor GNU Make, but rather - your filesystem. You are probably using a network-mounted filesystem like NFS, and the remote computer's time is earlier than on your system. So, when you created your compiled file, the remote time was, say X - 5 minutes, and your local time was X. After compilation, when you checked the created file time, the remote system happily reported: "it's X - 5 minutes!", and your system time was now, say, a little over X, and that did not make sense to you, since an hour ago you weren't building those files.

    ... apparently, some/all remote filesystem drivers don't account for these time differences between systems.