<div dir="ltr"><div><div>Hi David: Per your comment on the SO thread about escaping the ['s with a backslash:You mean something like this:<br><br>file( GLOB FILES "*" )<br>string( REPLACE "[" "\\[" FILES_UPD "${FILES}" )<br><br></div><div>That doesn't appear to work. I still get everything past the first [ run together in the foreach.<br></div><div><br></div>Thanks,<br></div>Allen<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 18, 2016 at 9:09 AM, David Cole <span dir="ltr"><<a href="mailto:DLRdave@aol.com" target="_blank">DLRdave@aol.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">"A single pair of square brackets with ; inside have also long been<br>
used to designate registry [key;value] pairs on Windows."<br>
<br>
<a href="http://stackoverflow.com/a/36085151/236192" rel="noreferrer" target="_blank">http://stackoverflow.com/a/36085151/236192</a><br>
<br>
<br>
HTH,<br>
David C.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On Fri, Mar 18, 2016 at 8:21 AM, Allen Barnett <<a href="mailto:allenbarnett5@gmail.com">allenbarnett5@gmail.com</a>> wrote:<br>
> Hi Petr: You're right! If I rename "c" to "c]", it treats the whole<br>
> "/home/allen/test/b[;/home/allen/test/c]" as an element of the list. The<br>
> other file names are correctly split apart.<br>
> Thanks,<br>
> Allen<br>
><br>
> On Fri, Mar 18, 2016 at 3:17 AM, Petr Kmoch <<a href="mailto:petr.kmoch@gmail.com">petr.kmoch@gmail.com</a>> wrote:<br>
>><br>
>> Hi Allen.<br>
>><br>
>> I'm not sure whether it's documented, but CMake interprets square brackets<br>
>> as escaping the semi-colon character (which means a semi-colon in square<br>
>> brackets will not work as a list item separator). You will probably have to<br>
>> translate the file names for CMake processing by replacing [ and ] with a<br>
>> different string, and replacing it back just before use outside of CMake.<br>
>><br>
>> Petr<br>
>><br>
>> On Thu, Mar 17, 2016 at 5:38 PM, Allen Barnett <<a href="mailto:allenbarnett5@gmail.com">allenbarnett5@gmail.com</a>><br>
>> wrote:<br>
>>><br>
>>> I inherited a set of files with somewhat unusual file names. In<br>
>>> particular, there were a couple of files whose names included a single<br>
>>> square bracket character. I processed these files with the file( GLOB ...)<br>
>>> command and then iterated over the resulting list with foreach. However, the<br>
>>> foreach command does not seem to break the resulting list apart correctly.<br>
>>> To make this concrete, I have a directory with files named "a", "b[", and<br>
>>> "c". file( GLOB FILES "*" ) returns the list:<br>
>>><br>
>>> /home/allen/test/b[;/home/allen/test/c;/home/allen/test/a<br>
>>><br>
>>> However,<br>
>>><br>
>>> foreach( FILE ${FILES} )<br>
>>>   message( ${FILE} )<br>
>>> endforeach()<br>
>>><br>
>>> just prints the same thing. That is, foreach does not split FILES into<br>
>>> separate pieces. If I rename "b[" to "b]" I see the same behavior. If I<br>
>>> rename "b[" to "b[]" (or even "b]["), then foreach successfully splits FILES<br>
>>> into the individual file names.<br>
>>><br>
>>> I'm using CMake 3.3.2. I see the same thing on linux and windows.<br>
>>><br>
>>> Thanks,<br>
>>> Allen<br>
>>><br>
>>> --<br>
>>><br>
>>> Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
>>><br>
>>> Please keep messages on-topic and check the CMake FAQ at:<br>
>>> <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
>>><br>
>>> Kitware offers various services to support the CMake community. For more<br>
>>> information on each offering, please visit:<br>
>>><br>
>>> CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
>>> CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
>>> CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
>>><br>
>>> Visit other Kitware open-source projects at<br>
>>> <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>>><br>
>>> Follow this link to subscribe/unsubscribe:<br>
>>> <a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br>
>><br>
>><br>
><br>
><br>
> --<br>
><br>
> Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
><br>
> Please keep messages on-topic and check the CMake FAQ at:<br>
> <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
><br>
> Kitware offers various services to support the CMake community. For more<br>
> information on each offering, please visit:<br>
><br>
> CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
> CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
> CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br>
</div></div></blockquote></div><br></div>