CMAKE_<LANG>_FLAGS_INIT does not accept lists
If I use a toolchain file that contains something like:
set(CMAKE_C_FLAGS_INIT "-target" "x86_64-unknown-freebsd13" "--sysroot=/Users/alex/cheri/output/freebsd-amd64" "-B/usr/local/Cellar/llvm/11.0.1/bin" "-Wno-unused-command-line-argument" "-Werror=implicit-function-declaration" "-Werror=format" "-Werror=incompatible-pointer-types" "-Werror=undefined-internal")
I get the following error when configuring:
ERR: CMake Error at /usr/local/Cellar/cmake/3.19.6/share/cmake/Modules/CMakeTestCCompiler.cmake:66 (message): The C compiler "/usr/local/Cellar/llvm/11.0.1/bin/clang" is not able to compile a simple test program. It fails with the following output: Change Dir: /Users/alex/cheri/build/wayland-freebsd-amd64-build/meson-private/cmake_epoll-shim/CMakeFiles/CMakeTmp Run Build Command(s):/usr/local/bin/ninja cmTC_63487 && [1/2] Building C object CMakeFiles/cmTC_63487.dir/testCCompiler.c.o FAILED: CMakeFiles/cmTC_63487.dir/testCCompiler.c.o /usr/local/Cellar/llvm/11.0.1/bin/clang --target=x86_64-unknown-freebsd13 --sysroot=/Users/alex/cheri/output/freebsd-amd64 -target;x86_64-unknown-freebsd13;--sysroot=/Users/alex/cheri/output/freebsd-amd64;-B/usr/local/Cellar/llvm/11.0.1/bin;-Wno-unused-command-line-argument;-Werror=implicit-function-declaration;-Werror=format;-Werror=incompatible-pointer-types;-Werror=undefined-internal -MD -MT CMakeFiles/cmTC_63487.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_63487.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_63487.dir/testCCompiler.c.o -c testCCompiler.c clang-11: error: argument to '-target' is missing (expected 1 value) clang-11: error: no input files /bin/sh: x86_64-unknown-freebsd13: command not found /bin/sh: --sysroot=/Users/alex/cheri/output/freebsd-amd64: No such file or directory /bin/sh: -B/usr/local/Cellar/llvm/11.0.1/bin: No such file or directory /bin/sh: -Wno-unused-command-line-argument: command not found /bin/sh: -Werror=implicit-function-declaration: command not found /bin/sh: -Werror=format: command not found /bin/sh: -Werror=incompatible-pointer-types: command not found /bin/sh: -Werror=undefined-internal: command not found ninja: build stopped: subcommand failed.
It works fine if I use a single space-separate string.
Ideally CMake would accept both lists and strings, but if that is not feasible, it would be good to document that it must be a single string in https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_FLAGS_INIT.html
I can obviously change my toolchain file, but it would nice if this worked as a string. In this case the toolchain file was generated by Meson and used a list instead of a single string (https://github.com/mesonbuild/meson/issues/8534).