Search code examples
stringsyntaxcmakestring-concatenation

How do you concat two literal strings in a CMake expression?


I've just read this:

How do you concatenate string in cmake

which is close to what I want, but not quite there. I want to concatenate two literal strings, without the concatenation would not be its own command. In programming language terms - I want to concatenate literal strings within an expression.

Is this possible? (I don't mind a high CMake version requirement.)

Note: This is not a question about breaking a single string onto multiple lines.


Solution

  • The CMake language http://cmake.org/cmake/help/v3.13/manual/cmake-language.7.html specification does not specify a way to concatenate string literals.

    string(CONCAT <output variable> [<input>...]) can be used to concatenate the input arguments and assign it to a new variable. This is different from the set command that would create a list based on the input arguments.