[CMake] General question about regex

Steven Truppe workbench at gmx.at
Tue Jun 4 13:19:40 EDT 2019


I found the solution:

     get_cmake_property(_vars VARIABLES)
     foreach(_var ${_vars})
         string(TOUPPER ${lib} lib_upper)
         if(_var MATCHES "^WITH_LIB_${lib_upper}_EXAMPLE_([A-Za-z]+)$")
	        message(STATUS "Number of examples found: ${CMAKE_MATCH_COUNT}")
         	message(STATUS "Number 1 found: ${CMAKE_MATCH_0}")
         endif()

     endforeach()

Now i've two problem - the CMAKE_MATCH_0 contains the hole string and
not only the part the is in the (), i need only the part from the () -
is there another command i can use for this ?


On 04.06.19 18:47, Kornel Benko wrote:
> Am Dienstag, 4. Juni 2019, 18:10:19 CEST schrieb Steven Truppe:
>> Hello again,
>>
>>
>> i've the following variable defined:
>>
>> set(WITH_LIB_GLAD_EXAMPLE_BASIC 1)
>>
>> And the if the line
>>
>>
>> foreach(_var VARIABLES)
>>
>>       if(_var MATCHES "WITH_LIB_GLAD_EXAMPLE_([A-Za-z]+)")
>>
>>           message(STATUS "Found a match")
>>
>> endforeach()
>>
>>
>> I never get the message "Found match", what am i doing wrong here ??
>>
>>
> What about the attached?
>
> 	Kornel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190604/877817ea/attachment.html>


More information about the CMake mailing list