Mat
Mat

Reputation: 4501

cMake SOURCE_GROUP multiple files?

for a VisualStudio project, i'd like cMake to put all files from a specific folder into 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 place only the first found cpp and the first found h file into that filter. the rest of the files in the folder will be placed in the default Filters

How to do it properly?

Upvotes: 5

Views: 5003

Answers (1)

Andrey Kamaev
Andrey Kamaev

Reputation: 30122

You need to pass full names, not globbing 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})

Upvotes: 7

Related Questions