Simple project, want some tips on file watching, continuous building

I have a simple project that builds an executable. I need some tips on how what conventions to follow. For example, I follow the convention of creating a build/ directory in the root of my project, then in there I issue “cmake …”. Then everything is contained in that folder and can easily be cleaned if necessary.

However, this seems a bit inconvenient still. Isn’t it by most (general, i.e. not CMake developers) preferable to be able to issue “make” in the root folder?

Next I would like to have some more advanced functionality. Many build systems nowadays offer a continuous build feature using file watching. I have created a simple version myself using old school Makefile and fswatch (https://github.com/dlidstrom/Duplo/blob/master/watch.sh).
Has anyone here implemented something similar that works nicely with CMake? Considering the fact that the convention is to build everything inside a temporary directory and issuing make there, how do you combine that with a file watch script?
Any tips are greatly appreciated, thanks!

Not sure what you mean here. You can issue make in the root build folder, right?
Now if your question is is out-of-source build preferable to in-source build ?
Then from my point of view, yes,
Out-of-source is the way to go if you don’t want to mess-up the version controlled files vs generated ones.
When I build software (with autotools or cmake or anything) my first option is out-of-source, unless the build system does not authorize it.
That said you can put the build directory anywhere you want.

Concerning the continuous question, I don’t know, I don’t use that, but I’m curious which build system do you use is offering some kind of continuous building?

Hi Eric

Thanks for your response. Yes I meant out-of-source build. I’ve now settled with building in a temporary folder in the root of my project.

Regarding file watching, yes it is a feature I’m seeing in modern tools. For example:

  • Webpack for frontend development
  • dotnet core

I’m sure there are many more. Traditionally I think C++ has not seen the need for that kind of rapid feedback, but even with my simple but effective custom script I am able to have a rapid feedback cycle that is very helpful. It would, however, be cool to see such support be available out-of-the-box from C++ build tools as well.