Converting part of a string to upper case in CMake

Viewed 5865

Is there a convenient way to transform a string that is all lower case so that the first character is upper case?

I currently have a working solution:

#PROTO_NAME is the lower-case string
string(SUBSTRING ${PROTO_NAME} 0 1 FIRST_LETTER)
string(TOUPPER ${FIRST_LETTER} FIRST_LETTER)
string(REGEX REPLACE "^.(.*)" "${FIRST_LETTER}\\1" PROTO_NAME_CAP "${PROTO_NAME}")

The result is in the PROTO_NAME_CAP variable. Is there a simpler or more convenient way to achieve this?

1 Answers
Related