Is there any software for recompiling a CMake-based software project on file changes?
I'm working on a C++ software project which uses CMake as its build system. The software is built on Mac OS/X, Linux as well as Windows.
In order to improve my usual hack/compile/test cycle, I was wondering whether there is maybe some daemon-like software which is aware of all the source files considered by a CMake project. Whenever any of the source files is modified, the daemon notices this and rebuilds the affected targets. The idea is that the 'compile' step in my cycle will become faster because it can just return immediately saying 'Nothing to do since your friendly neighborhoud build daemon rebuilt all files already.'.
Does anybody know of existing software which can do so? If not - is it somehow possible to export the list of source files considered by CMake so that I could write a little daemon myself which monitors those files and re开发者_如何转开发-runs make
(or whatever is appropriate for the chosen generator) automatically? In the best case, I would also get the dependency tree so that I could maybe skip checking all dependencies over and over again and just update the targets I need.
I've used JNotify for sucessfully monitoring file changes without much hassle.
It works for all operating systems you mentioned and file change detection is almost instantanious. It can detect file creation, deletion, modification, etc.
A nice code sample can be found here.
You can do something like this:
class CMakeListener implements JNotifyListener {
public void fileModified(int wd, String rootPath, String name) {
// if a file is a cpp or hpp file, execute CMake
}
}
and your CMake task should be nicely automated.
精彩评论