David
David

Reputation: 9965

How do you escape a semicolon in COMPILE_FLAGS property of cmake?

I need to get this as a result in the preprocessor definitions of the msvc generator:

MYPATH=\"d:\\;.\\Lib\"

But when I use the following escape sequence in set_source_files_properties:

set_source_files_properties(source.c PROPERTIES COMPILE_FLAGS "-DMYPATH=\\\"d:\\\;.\\\\Lib\\\"")

the generated result is: MYPATH=\"d:\";".\Lib\"

Note the double-quoted semicolon. Is there a quoting workaround to allow unquoted semicolons?

Upvotes: 4

Views: 1476

Answers (1)

Sergei Nikulov
Sergei Nikulov

Reputation: 5135

AFAIR, cmake treat ; as list separator, so it behaves in such way for properties as per documentation.

PROPERTY [value1 [value2 ...]

Probably you've better to try something like this - make it string variable and then try substitute it.

set(MY_PATH "\"d:\\\;.\\\\Lib\\\"")
set_source_files_properties(source.c PROPERTIES COMPILE_FLAGS ${MY_PATH})

HTH, Sergey

Upvotes: 3

Related Questions