You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[CMake] Handle multiple flags in ADDITIONAL_COMPILE_FLAGS properly
When multiple space-separated compile flags are specified in an
`ADDITIONAL_COMPILE_FLAGS` cache string, the resulting flags are
enclosed by double quotes because `ADDITIONAL_COMPILE_FLAGS` is a
string (i.e. not a list) and CMake `target_compile_options` treats the
multiple space-separated arguments as single argument containing spaces.
For example, when libcxx is configured with the following multiple
space-separated additional compile flags:
cmake ... "-DLIBCXX_ADDITIONAL_COMPILE_FLAGS=--flag1 --flag2" ...
The resulting compiler command line is as follows:
cc ... "--flag1 --flag2" ...
The above can be problematic for some compilers -- for instance, GCC
treats it as a file path and prints out an error.
This patch, by calling `separate_arguments` on
`ADDITIONAL_COMPILE_FLAGS` to convert it into the standard
semicolon-separated list form, which is properly handled by
`target_compile_options`, ensures that multiple compile flags are
handled as such.
With this change, the resulting compiler command line is as follows:
cc ... --flag1 --flag2 ...
Signed-off-by: Stephanos Ioannidis <[email protected]>
0 commit comments