I used JNotify to successfully monitor file changes without much trouble.
It works for all the operating systems you mentioned, and detecting file changes almost instantly. It can detect creation, deletion, change, etc.
A good code example can be found here .
You can do something like this:
class CMakeListener implements JNotifyListener { public void fileModified(int wd, String rootPath, String name) {
and your CMake task should be well automated.
source share