[CMake] Need help with GLOB expression

Bill Hoffman bill.hoffman at kitware.com
Sun Mar 29 17:14:40 EDT 2009


James Bigler wrote:
> Ah, yes.  I also was getting globbing expressions and regular
> expressions mixed up.
> 
>>From the docs (and experimentation), it looks like CMake only supports
> *, ?, and [], but not {} which would be required to do what we want:
> 
> file(GLOB_RECURSE sources "*.{h,cpp}")
> 

CMake uses a simple conversion from glob to regex, the code for that can 
be found here:

http://public.kitware.com/cgi-bin/viewcvs.cgi/Source/kwsys/Glob.cxx?revision=1.16&root=CMake&view=markup

It does a simple glob with *,?, and [], and that is about it.

The best thing to do would be to try using a glob expression from a bash 
shell and ls.  For example, the first one you gave does not work 
.[hi]pp.  It was added to cmake to give simple globs like *.c *.cxx *.h, 
etc.

-Bill


More information about the CMake mailing list