[CMake] Spaces in conditional output of generator expressions
Neil Carlson
neil.n.carlson at gmail.com
Sat Jun 2 18:47:18 EDT 2018
I'm attempting to use a generator expression to conditionally add compile
options. No problem if it is a single option, but I can't figure out how to
manage multiple options (in a single command).
For example, this works:
add_compile_options($<$<COMPILE_LANGUAGE:C>-Wall>)
As does this:
add_compile_options(-Wall -Wextra)
But not this:
add_compile_options($<$<COMPILE_LANGUAGE:C>-Wall -Wextra>)
Nor this:
add_compile_options($<$<COMPILE_LANGUAGE:C>"-Wall -Wextra">)
Or any other variation I could think of. Either the space breaks the
generator expression, or I get a quoted version of the options that the
compiler sees as a single "option" it doesn't understand.
Is there some way of doing this?
PS: I'm trying to avoid using CMAKE_C_FLAGS. My understanding is that
variable is meant for the end user's use. Am I mistaken about that?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180602/dea6ce9a/attachment.html>
More information about the CMake
mailing list