source_group without FILES with Visual Studio generator
In the generated VS project all source files are under "Source Files" filter by default. The project is simple and this extra folder bothers me, so I tried source_group CMake command to get rid of it.
According to the documentation, source_group can be used without FILES option (it's marked optional). It's logical and handy if I want to apply it to all source files, so I tried the following variants and none of them work without FILES:
add_executable(App1 main.cpp subdirA/test1.cpp subdirB/test2.cpp)
# These do not work:
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}")
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" PREFIX "")
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" PREFIX ".")
# This works but verbose because I need to repeat file list, or introduce variable for it:
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES main.cpp subdirA/test1.cpp subdirB/test2.cpp)
# This one would be super-handy if it worked (meaning root to be current dir by default):
source_group(TREE)