MantisBT - CMake
View Issue Details
0011714CMakeCMakepublic2011-01-17 10:312011-01-17 11:06
Markus Elfring 
Brad King 
normalfeaturealways
closedsuspended 
CMake 2.8.3 
 
0011714: Directly reading data from a file into variables
I would like to read some data from a file into CMake variables.

Your programming supports this kind of context-dependent data extraction with two steps so far.
Example:
1. file(STRINGS ${file_name} ${variable_for_file_data} REGEX ${pattern1})
2. string(REGEX REPLACE ${pattern2} "\\1" ${variable_for_data_element} ${variable_for_file_data})

This proccessing approach requires the evaluation of two similar regular expressions. This is not as efficient as I imagine it could be.
- I do not really need any replacement features for this use case. It seems that it is only needed at the moment because the subfunction "string(REGEX REPLACE ...)" is the only one with (partly documented) support for subexpressions in regular expressions.
- It would be convenient if parts from the input lines could be directly assigned to variables by the file command.

Would you like to add the capability for improved data selection to a variant of the function "file(STRINGS ...)"?
No tags attached.
Issue History
2011-01-17 10:31Markus ElfringNew Issue
2011-01-17 11:06Brad KingNote Added: 0024756
2011-01-17 11:06Brad KingStatusnew => closed
2011-01-17 11:06Brad KingAssigned To => Brad King
2011-01-17 11:06Brad KingResolutionopen => suspended

Notes
(0024756)
Brad King   
2011-01-17 11:06   
The issue tracker is meant for monitoring specific changes to CMake that need developer attention. We have better things to do than answer questions here. Please bring general discussion to the mailing list where it will get more exposure.

CMake is not a general purpose programming language. Files read by CMake while configuring the project should be small enough that double-regex processing is not a performance bottleneck. If you need to do high-speed data processing use a scripting language or add a C program to your project that runs at build time to do necessary processing.

If you feel this is an insufficient resolution please come back with an actual proposed patch.