[CMake] File names with unbalanced square brackets

Allen Barnett allenbarnett5 at gmail.com
Thu Mar 17 12:38:01 EDT 2016


I inherited a set of files with somewhat unusual file names. In particular,
there were a couple of files whose names included a single square bracket
character. I processed these files with the file( GLOB ...) command and
then iterated over the resulting list with foreach. However, the foreach
command does not seem to break the resulting list apart correctly. To make
this concrete, I have a directory with files named "a", "b[", and "c".
file( GLOB FILES "*" ) returns the list:

/home/allen/test/b[;/home/allen/test/c;/home/allen/test/a

However,

foreach( FILE ${FILES} )
  message( ${FILE} )
endforeach()

just prints the same thing. That is, foreach does not split FILES into
separate pieces. If I rename "b[" to "b]" I see the same behavior. If I
rename "b[" to "b[]" (or even "b]["), then foreach successfully splits
FILES into the individual file names.

I'm using CMake 3.3.2. I see the same thing on linux and windows.

Thanks,
Allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160317/4c9b627f/attachment.html>


More information about the CMake mailing list