in the kate build plugin I’d like to react if cmake was rerun on the current build tree (in order to read the updated file API files).
Is there some file I could “watch” ?
I’d prefer not to have different cases for watching a regenerated “Makefile” or “build.ninja” or projectname.sln depending on which generator is used.
The reply files are different on every run if I understand correctly, so I cannot watch one of them.
Maybe the CMakeCache.txt file in the build directory. I don’t know if its timestamp gets updated if its contents don’t change, but you should be able to test that fairly easily to confirm one way or the other.
Technically, CMakeCache.txt will be updated at the end of the configure phase. This only matters here because while cmake always executes both the configure and generation phases, ccmake and CMake-GUI require the user to execute them separately. So it would be possible to encounter situations where the user executes the configure phase but not the generation phase. That would cause CMakeCache.txt to be updated, but not the project files (Makefile, build.ninja, etc.). It’s probably not a corner case you’d really need to support though, I suspect.
No, the CMakeCache.txt is only modifed if actually some setting has changed.
It’s the other way round, if the CMakeCache.txt has changed, then cmake runs again. Wouldn’t it be an endless loop otherwise ?
I looked a bit around and found the file CMakeFiles/cmake.check_cache, which says:
“# This file is generated by cmake for dependency checking of the CMakeCache.txt file”
So it looks like this file is modified by every cmake run.
But can I rely on this file, or may it change in the fuure ? And since when does it exist ?
The CMakeCache.txt timestamp is always updated when CMake re-runs. That’s used to check if the generated build system is up to date w.r.t. the CMake inputs. You may rely on it. EDIT: Sorry, this is totally wrong. CMakeCache.txt is among the CMake inputs.
Not sure I’m not misunderstanding something.
If I “touch” CMakeCache.txt e.g. at 9:00, then wait 5 minutes, and then build, cmake is rerun.
ls -al still shows the time 9:00 for CMakeCache.txt. Building then again of course does not trigger a rerun of cmake.
The file CMakeFiles/cmake.check_cache OTOH does show the time of when cmake was run, i.e. 9:05.
in the kate build plugin I’d like to react if cmake was rerun on the current build tree (in order to read the updated file API files).
See the file-api docs on the reply index file. Clients of the file-api should watch the .cmake/api/v1/reply/ directory for the appearance of new index-*.json files.
Currently I read these files if “I” trigger the rerun of cmake, but I don’t want to read them whenever a build has been run.
So I have to use a filesystem watcher on the directory .cmake/api/v1/reply/ ?
I’m wondering whether it is cross-platform cross-filesystem reliable that I’ll be notified that the directory has been modified if a new file has been written into the directory.