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?
结果在PROTO_NAME_CAP变量中。有没有更简单或更方便的方法来实现这一目标?
1 个解决方案
#1
5
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.
在CMake中没有内置的解决方案。如果要使事物更具可读性,则只能隐藏函数后面的代码。
#1
5
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.
在CMake中没有内置的解决方案。如果要使事物更具可读性,则只能隐藏函数后面的代码。