0

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.

einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • The accepted answer to the question you linked seems already to demonstrate exactly what you describe. Although it *also* demonstrates assigning the result to a variable, to the best of my knowledge that part is not essential. If you think differently then perhaps a [mcve] would clarify what you're asking. – John Bollinger Feb 02 '19 at 15:52
  • @JohnBollinger: See edit. I should have explained why that one's not a solution for me either. As for an MCVE - you can only ask for an example if one can be provided. I'm asking "how to do X?" - I cann't give an example. If you're asking "what do you need this for"? Let's just say it's curiosity + programming style. – einpoklum Feb 02 '19 at 16:14
  • I still don't follow. If you have *literal* strings to concatenate, then what prevents you from just writing the concatenation as a single string? – John Bollinger Feb 02 '19 at 17:46
  • @JohnBollinger: I didn't say something prevents me from doing so. But to humor you: Suppose that they're long and I want them on separate lines. – einpoklum Feb 02 '19 at 17:50
  • I'm just trying to understand what you're asking. It sounds like it's actually more about how to *split* long strings across multiple lines, and that already has [an answer](https://stackoverflow.com/questions/7637539/how-to-split-strings-across-multiple-lines-in-cmake/16703203). – John Bollinger Feb 02 '19 at 18:32
  • Possible duplicate of [How to split strings across multiple lines in CMake?](https://stackoverflow.com/questions/7637539/how-to-split-strings-across-multiple-lines-in-cmake) – John Bollinger Feb 02 '19 at 18:33
  • @JohnBollinger: That's not what I asked, and stop trying to manipulate me/my question. – einpoklum Feb 02 '19 at 18:35
  • I am not trying to manipulate anything, but since we seem unable to communicate I will be moving on now. I hope you get an answer that satisfies you. – John Bollinger Feb 02 '19 at 18:47
  • Like @JohnBollinger, I don't see your point. Why [the answer](https://stackoverflow.com/a/18003562/3440745) to the referenced question does not answer your question? And why the referenced question is not a duplicate of yours? An example would be really helpful for understand the question. Not [mcve], but an example of **input** and which **output** (effect) you want to achieve. – Tsyvarev Feb 02 '19 at 22:08
  • This is really vague. `string(CONCAT [...])` concatenates the strings. It's in the linked question and answer. https://cmake.org/cmake/help/v3.13/manual/cmake-language.7.html doesn't specify much other than commands and their arguments. What other programming expression are you expecting to exist? – fdk1342 Feb 02 '19 at 22:09
  • @Fred: I'm looking for something which does not involve a named output variable for the concatenation. I'm looking for something like a concatenation operator on strings. – einpoklum Feb 02 '19 at 22:29
  • @einpoklum According to the link I posted there is none specified in the language. – fdk1342 Feb 02 '19 at 22:50
  • @Fred: Ok, then - can you make that an answer I can accept? – einpoklum Feb 02 '19 at 22:54

1 Answers1

1

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.

fdk1342
  • 3,274
  • 1
  • 16
  • 17