I need to write regex in cmake lists to replace all ends of lines to spaces. I tried this, but it is incorrect
STRING(REGEX REPLACE "/\s+/g" " " output ${input})
The command expects a regular expression, but you're passing a sed argument in.
If you really want to replace all line-end characters with spaces, there's even no need for a regex at all. Just do this:
string(REPLACE "\n" " " output ${input})
\r ? or \r\n ?input, of course. But CMake file I/O is text-based by default, so if input was read by CMake from a file native to the system on which you're running, you shouldn't encounter \r at all.It is possible to do that by
string(REGEX REPLACE "[\r\n]*" " " output ${input})
Interestingly a relevant problem was to convert it into a list like the following,
string(STRIP ${input} stripppedinput)
string(REGEX REPLACE "[\r\n]*" ";" output ${strippedinput})
string(REGEX REPLACE "[\r\n]*" " " output ${input})