How to automatically add header and source files to executable without file(GLOB )?

Hello. For now, I use file(GLOB_RECURSE source_list "*.cpp" "*.h") in order to automatically add new files to project. I work with Clion and it “doesn’t like” this function. I mean, when I want to generate function’s definition, Clion opens MOC generated files (I work with Qt). The problem has started to occur when I deleted source and headers variable definiotions (set()) and added file(GLOB …). What’s the best way to substitute file()?

Using file(GLOB_RECURSE...) to include source files is a bad idea, the doc is clear on this subject:

You should maintain an explicit list of files in your CMakeLists.txt.
If those file are hand-edited file you have to add them by hand in CMakeLists.txt just like you will add them manually in your favorite VCS.

If the file are generated files this is another story, you may have look at this blog entry: