My problem is that I am forced to rerun CMake each time I add a new source file, which is really annoying... Is there any way CMake could detect newly added source file auto
CMake does not have functionality to observe a folder. Some OS (e.g. MacOS X) can execute an action in case a folder was changed. Some IDEs (e.g. QtCreator V4.1 and newer) trigger an re-run of CMake in case any of the CMake files where changed.
I do not know your use case but I recommend not to use file(GLOB ...)
. It is better to know which files are part of your project.