Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting part of a string to upper case in CMake

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?

like image 281
Anthony Avatar asked Aug 07 '12 12:08

Anthony


1 Answers

There is no built-in solution for this in CMake. You can only hide your code behind a function if you want to make things more readable.

like image 176
languitar Avatar answered Oct 11 '22 09:10

languitar