CMake SOURCE_GROUP multiple files?

for a VisualStudio project, I would like cMake to put all the files from a specific folder in a specific filter.

I tried:

SOURCE_GROUP(Math FILES 
    ${CMAKE_CURRENT_SOURCE_DIR}/src/Math/*.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/src/Math/*.h
)

however, this will only place the first cpp found and the first h file found in this filter. other files in the folder will be placed in the default filters

How to do it right?

+5
source share
1 answer

You need to pass the full names, not the substitution expressions:

FILE(GLOB source_files
    ${CMAKE_CURRENT_SOURCE_DIR}/src/Math/*.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/src/Math/*.h
)

SOURCE_GROUP(Math FILES ${source_files})
+7
source

All Articles