CMAKE_<LANG>_COMPILER_TARGET settable on the command line?
The documentation for CMAKE_<LANG>_COMPILER_TARGET
, https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_TARGET.html, says:
This variable may only be set in a toolchain file specified by the CMAKE_TOOLCHAIN_FILE variable.
However in practice in one test I did, it worked just fine to set it up on the command line with e.g. -DCMAKE_CXX_COMPILER_TARGET
too, e.g. for cross compiling with Clang like -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_COMPILER_TARGET=x86_64-w64-mingw32
.
Is this way of setting the variable something that is discouraged and might break subtly in the future, or should the documentation be amended to clarify what this sentence tried to say?