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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With