[CMake] FILE command working

Michael Wild themiwi at gmail.com
Fri Jul 9 07:55:34 EDT 2010


It works for me if I use

file(STRINGS test.txt test_str)
foreach(line IN LISTS test_str)
  message("line = ${line}")
endforeach()

Problem is that empty lines result in empty elements in test_str, which are discarded by the old-style foreach loop over a list.

Michael

On 9. Jul, 2010, at 13:27 , David Cole wrote:

> Are some of the lines empty by any chance?
> 
> Empty elements are not iterated in a foreach of a list.
> 
> Nor (I would expect, I have not verified) is an empty string considered a
> string for reporting by file(STRINGS ...
> 
> 
> HTH,
> David
> 
> 
> On Fri, Jul 9, 2010 at 5:24 AM, Johny <Johny.Jose at cern.ch> wrote:
> 
>> Hi,
>> 
>> I was working with the FILE(STRINGS filename lineList) and i discovered
>> that i end up getting a list which has a lesser number of strings than the
>> actual lines in the file. However this happens with only some files, i went
>> through those but they seem to be regular files. When i count the no of new
>> lines in the files i get the correct no of lines for the file.
>> 
>> This has led me to believe that the FILE strings command is at fault
>> somehow. How does it work?
>> 
>> Cheers!
>> Johny
>> 
>> 
>> _______________________________________________
>> Powered by www.kitware.com
>> 
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>> 
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>> 
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
>> 
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list