[CMake] Handle multiple flags in ADDITIONAL_COMPILE_FLAGS properly #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When multiple space-separated compile flags are specified in an
ADDITIONAL_COMPILE_FLAGS
cache string, the resulting flags are enclosed by double quotes becauseADDITIONAL_COMPILE_FLAGS
is a string (i.e. not a list) and CMaketarget_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:
The resulting compiler command line is as follows:
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
onADDITIONAL_COMPILE_FLAGS
to convert it into the standard semicolon-separated list form, which is properly handled bytarget_compile_options
, ensures that multiple compile flags are handled as such.With this change, the resulting compiler command line is as follows: