Using Cmake with Qt Creator

You can add files using glob expression in your CMakeLists.txt, like this:

file(GLOB SRC . *.cpp)
add_executable (your_exe_name ${SRC})

Cmake will pick your new cpp files next time you run it and QtCreator will show them in the project browser.

Update

This solution may be useful but as noted in comments - this is not a good practice. Every time somebody add new source file and commit changes, you need to rerun cmake to build all the sources. Usually I just touch one of the CMakeLists.txt files if my build is broken after I pool recent changes from repository. After that make will run cmake automatically and I didn't need to run it by hands. Despite of that I think that explicit source lists in CMakeLists.txt is a good thing, they called thing CMake Lists for a reason.


When you add new files in QtCreator using the "New File or Project..." dialog it only creates the files on disk, it doesn't automatically add the files to the CMakeLists.txt. You need to do this by hand by editing the CMakeLists.txt file.

The next time you build the project, CMake will be re-run, and QtCreator will pick up the new files and show them in the project browser.