I want to create a list of all .c, .h, .S files in a folder.
file(GLOB SRCS *.[chS]) fails to match .S files. file(GLOB SRCS *.[chs]) does match all those files (on Windows) but it doesn’t look correct because .S files end with capital S.
My first response would be “Don’t do it!”. Globbing for source files is actively discouraged by the CMake docs, and I regularly see problems in client projects that are caused by file globbing. In most cases, it is trivial to generate the list of files once and put that in your CMakeLists.txt file, and it is also typically trivial to maintain that list.
If you really must use file globbing (and there are times where it is unavoidable), then to answer your question, you can only use basic wildcard patterns. There is no [] support. (EDIT: There is [] support, I’d just never actually seen that used!) But you can list multiple patterns, which allows you to get the result you’re after:
file(GLOB SRCS *.c *.h *.S)
If you are going to use file(GLOB...), I urge you to consider using the CONFIGURE_DEPENDS keyword. That won’t solve all problems, but it will at least reduce them.
Leaving my previous comment there, I since realised your question is more about the [...] part of the globbing pattern. Please try my alternative with three separate patterns. If that also shows the same problem with it not matching *.S files on Windows, that may warrant further investigation.
Please also indicate what CMake version you’re using.