Why does CMake FILE(READ) ignore semicolons in my file?

1.4k views Asked by At

I have a css file (which I want to parse and adapt for Qt, but that's not the problem). Let's say this one:

QLineEdit:hover:not(focus),
QWidget QPlainTextEdit:not(hover):not(focus) {
    border-color: #5575b0;
}

I made a CMake script to replace not(...) by !... : that part of the script works correctly.

The problem is that CMake removes the semicolons (;) at the end of lines. When I do:

file(READ ${INPUT_FILE_PATH} CONTENT)
message(${CONTENT})

The output is, unfortunately :

QLineEdit:hover:not(focus),
QWidget QPlainTextEdit:not(hover):not(focus) {
    border-color: #5575b0 // <-- missing comma here !
}

As anyone an idea why this happen ? And how to avoid it ?

1

There are 1 answers

1
Olivier CLERO On BEST ANSWER

I found out what the problem is : CMake considers my input as a list, in which elements are separated by a comma (;).

To avoid that, we have to add quotes to the variable, like this "${MY_VAR}" :

message("${CONTENT}")