View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015369CMakeCMakepublic2015-01-23 14:322015-06-01 08:38
ReporterJoakim Söderberg 
Assigned To 
PriorityhighSeveritymajorReproducibilityalways
StatusclosedResolutionwon't fix 
PlatformOSOS Version
Product VersionCMake 2.8.12.2 
Target VersionFixed in Version 
Summary0015369: file(STRINGS file VAR) fails to read entire file
DescriptionI am experiencing some weird issues with file(STRINGS.

It fails to read my entire file. The file is 2529 lines long, but CMake only read 1885. Or well it reads the entire file, but then stops splitting it up into lines, instead the last list entry consists of all the lines between 1885-2529.
Steps To Reproducecmake -DFILE=thefile.gcov -P testscript.cmake


testscript:

file(STRINGS ${FILE} LIST)
list(LENGTH LIST LIST_COUNT)
message("${LIST_COUNT}")
Additional InformationI have not been able to test with a later CMake yet. But I hope there is some workaround for this for older versions as well.
TagsNo tags attached.
Attached Files? file icon thefile.gcov [^] (93,126 bytes) 2015-01-23 14:32

 Relationships

  Notes
(0037793)
Brad King (manager)
2015-01-23 14:37

The file contains lines with unmatched square brackets. As documented here:

 http://www.cmake.org/cmake/help/v3.1/manual/cmake-language.7.html#lists [^]

unmatched square brackets cause lists to not be split.

CMake is not a general-purpose language suitable for data processing.
(0037794)
Joakim Söderberg (reporter)
2015-01-23 14:51

Ok, so I'm just screwed then? No way around this, except adding matching brackets (which I have confirmed works) as comments in the file.

So I'm totally in the wrong even trying something like this?:
https://github.com/JoakimSoderberg/coveralls-cmake/blob/master/cmake/CoverallsGenerateGcov.cmake [^]

Actually this is not the first time I've run into problems with how lists works. But I guess code like the above is better to write in an external C program that is compiled and passed the input.
(0037795)
Brad King (manager)
2015-01-23 14:58

Re 0015369:0037794: I don't think implementing coverage file parsing in the CMake language is a good idea.

CMake language lists were designed to do lists of source files. Their restrictions with respect to ";", "[", and "]" were necessary for compatibility with existing behavior at the time they were introduced. It was never designed to be general purpose.

At best you could hack around the limitation by using string(REPLACE) to substitute placeholders for "[" and "]" before doing anything else with the result of file(STRINGS).
(0037799)
Joakim Söderberg (reporter)
2015-01-23 15:21

Thanks that fixed it!
(0038856)
Robert Maynard (manager)
2015-06-01 08:38

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2015-01-23 14:32 Joakim Söderberg New Issue
2015-01-23 14:32 Joakim Söderberg File Added: thefile.gcov
2015-01-23 14:37 Brad King Note Added: 0037793
2015-01-23 14:37 Brad King Status new => resolved
2015-01-23 14:37 Brad King Resolution open => won't fix
2015-01-23 14:51 Joakim Söderberg Note Added: 0037794
2015-01-23 14:58 Brad King Note Added: 0037795
2015-01-23 15:21 Joakim Söderberg Note Added: 0037799
2015-06-01 08:38 Robert Maynard Note Added: 0038856
2015-06-01 08:38 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team