Generating for Xcode using CMake 3.15.3:
Why does:
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/${my_source_subdir} FILES ${my_files})
do something sensible (all source files in a nested structure), while
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/${my_source_subdir})
lists all files under a directory called TREE?
If it can implicitly find the files, why doesn’t it implicitly use them to create nested source groups?
McMartin
(Alain Martin)
2
I guess that is due to the legacy signature of source_group
:
source_group(<name> <regex>)
which is equivalent to
source_group(<name> REGULAR_EXPRESSION <regex>)
(see at the bottom of https://cmake.org/cmake/help/latest/command/source_group.html)
In your case, I guess you could use
source_group(TREE <root> PREFIX <prefix>)
to avoid passing FILES
.
I hope this helps!
Andrew
3
I tried
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/${my_source_subdir} PREFIX source)
and that doesn’t seem to do anything. I just get the traditional Sources and Headers with all files in there flat.
At this point, it seems the option to omit FILES from source_group(TREE) is meaningless.