source_group CMake command isn't working
You need to use the files in an actual target. For example they must be used in an add_library
or add_executable
statement, then they will be in a folder within that project. Also, I use ''/'' rather than \\
as a separator. You may also want to use set_property(GLOBAL PROPERTY USE_FOLDERS ON)
to have the predefined cmake projects go into their own solution folder.
There is a new command since CMake 3.8 to automatically filter your files according to the folder structure relative to a certain path.
Here is a small example where the SRC_BUILD_FILES is a set containing all the files you want to filter. The filtering occurs relative to a certain base path, which is set using CMAKE_CURRENT_SOURCE_DIR in this example, but it can be any folder. The PREFIX name (here: Implementation) can be set to your liking and will contain the filtered set.
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}"
PREFIX "Implementation"
FILES ${SRC_BUILD_FILES})
So there is no need for globbing or manually re-iterating folder names in your cmake script.