I have following structure
Main (dir)
+-- CMakeLists.txt
+-- File.cpp
+-- File.hpp
+-- Dir (dir)
+-- CMakeLists.txt
I wanted to comment on https://stackoverflow.com/users/3987854/squareskittles 's answer, but I couldn't due to the lack of "reputation" ?
Anyway,
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCE_LIST})
works like a charm, but I also needed to set this:
set_property(GLOBAL PROPERTY USE_FOLDERS ON)