source_group(TREE ...) ignores files in root directory
With CMake 3.10.1, using the Visual Studio 2017 generator :
$ find
.
./CMakeLists.txt
./root.c
./sub
./sub/sub.c
cmake_minimum_required(VERSION 3.10.1)
set(sources root.c sub/sub.c)
add_executable(foo ${sources})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${sources})
source_group(TREE ...)
ignores root.c
:
Source Files/
root.c
sub/
sub.c
CMakeLists.txt
OTOH if a prefix is specified, the expected grouping is generated :
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX prefix FILES ${sources})
prefix/
root.c
sub/
sub.c
CMakeLists.txt
Passing an empty prefix doesn't help : files located in the root directory aren't touched as if no prefix was used.
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX "" FILES ${sources})
Potentially related to issue #17581 (closed)