Tuesday, July 26, 2022

[SOLVED] CMake Regex to convert lower case to upper case

Issue

Hi i'm trying to convert a string of lowercase letters to uppercase using regex in a cmake file.

The command i'm using is:
string(REGEX REPLACE match replace output input)

Does anyone know how to specify that each lower case letter be replaced with its uppercase counterpart using cmake's regex facility?


Solution

I don't think it is possible to do that with a CMake regular expression. If you just want to convert a string to uppercase you can use the TOUPPER string function:

string(TOUPPER <string1> <output variable>)

Example to convert the contents of a variable to uppercase:

string(TOUPPER ${VARNAME} VARNAME)


Answered By - sakra
Answer Checked By - Pedro (WPSolving Volunteer)