[CMake] How to assign data from subexpressions of regular expressions to CMake variables?

Michael Wild themiwi at gmail.com
Thu Jan 20 07:39:52 EST 2011


On 01/20/2011 12:10 PM, SF Markus Elfring wrote:
>> Thanks for your help to make CMake better,
> 
> Is the command variant "string(REGEX REPLACE ...)" completely documented?
> 
> Can multiple variables be specified that will receive the data from the
> evaluation of subexpressions in the passed regular expression?
> 
> Regards,
> Markus

AFAIK no, but you can "misuse" if(<string|varname> MATCHES <pattern>)
for this. It stores the groups in CMAKE_MATCH_<n> where <n> is {0..9}.
Match 0 is always the whole match of <pattern> and match 1 is the
contains the first group.

Michael


More information about the CMake mailing list