[CMake] File names with unbalanced square brackets

Allen Barnett allenbarnett5 at gmail.com
Fri Mar 18 08:29:54 EDT 2016


Hi Marc: Thanks for the tip. I learned some new CMake syntax! But, it
doesn't seem to solve the problem. It appears that the semi-colon quoting
property of the bracket wins in this case, too.
Thanks,
Allen

On Fri, Mar 18, 2016 at 3:50 AM, CHEVRIER, Marc <marc.chevrier at sap.com>
wrote:

> I think you can resolve your problem with the following syntax for foreach
> command:
> Foreach (FILE IN LISTS FILES)
>
> In this case the list is not expanded in your source so square brackets is
> no longer interpreted…
>
>
> From: CMake <cmake-bounces at cmake.org> on behalf of Petr Kmoch <
> petr.kmoch at gmail.com>
> Date: Friday 18 March 2016 at 08:17
> To: Allen Barnett <allenbarnett5 at gmail.com>
> Cc: "cmake at cmake.org" <CMake at cmake.org>
> Subject: Re: [CMake] File names with unbalanced square brackets
>
> Hi Allen.
>
> I'm not sure whether it's documented, but CMake interprets square brackets
> as escaping the semi-colon character (which means a semi-colon in square
> brackets will not work as a list item separator). You will probably have to
> translate the file names for CMake processing by replacing [ and ] with a
> different string, and replacing it back just before use outside of CMake.
>
> Petr
>
> On Thu, Mar 17, 2016 at 5:38 PM, Allen Barnett <allenbarnett5 at gmail.com>
> wrote:
>
>> 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
>>
>> --
>>
>> Powered by www.kitware.com
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Kitware offers various services to support the CMake community. For more
>> information on each offering, please visit:
>>
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/cmake
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160318/75b22b21/attachment.html>


More information about the CMake mailing list