Is there any software for recompiling a CMake-based software project when a file changes?

I am working on a C ++ software project that uses CMake as its build system. The software is built on Mac OS / X, Linux, and Windows.

To improve my regular hack / compile / test loop, I was wondering if any demon-like software is possible that knows about all the source files the CMake project is looking at. Whenever any of the source files changes, the daemon notices this and restores the affected targets. The idea is that the β€œcompile” step in my loop will be faster, because it can return immediately, saying β€œdo nothing, because your friendly neighbor-friend daemon has already rebuilt all the files.”

Does anyone know of existing software that can do this? If not - is it possible to somehow export the list of source files reviewed by CMake so that I can write a small daemon that monitors these files and runs make automatically (or something suitable for the selected generator)? At best, I would also get a dependency tree so that I can try checking all the dependencies again and again and just update the desired goals.

+4
source share
1 answer

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) { // if a file is a cpp or hpp file, execute CMake } } 

and your CMake task should be well automated.

+2
source

Source: https://habr.com/ru/post/1338716/


All Articles