QtCreator CMake project - how to show all project files

Irbis picture Irbis · Feb 7, 2015 · Viewed 24.9k times · Source

I use QtCreator to open CMake project. Some directories apart from CMakeLists.txt contains only headers files *.h and for those directories QtCreator in the project tree view shows only CMakeLists.txt. How to fix that ? I need to see all project files from QtCreator.

Answer

Slava picture Slava · Nov 10, 2015

Viewing project as a file system is not a solution at all cause your project editor settings for example would not apply. And I do not like to add headers to executable target, cause they do not actually belong there. You effectively cripple the project file to work nicely with one particular IDE... not good. The cleaner option IMHO would be:

FILE(GLOB_RECURSE LibFiles "include/*.hpp")
add_custom_target(headers SOURCES ${LibFiles})

As a bonus you get your includes shown in a separate folder. (borrowed from https://cmake.org/pipermail/cmake/2012-August/051811.html)