CMAKE_<LANG>_COMPILER documentation is inaccurate
For c
, c++
, and fortran
, a change made 8 years ago here deliberately changed how cmake locates and sets the compiler for those languages when using the Visual Studio
generator, but did not update the documentation. Additional exceptions for Green Hills MULTI
and XCode
have since been added.
For almost all cases, a user may set CMAKE_<LANG>_COMPILER
to override the defaults. However, when using one of the above generators for those languages cmake goes right ahead and does a search in the default locations regardless, leading to unpredictable and often broken behaviour if using a custom compiler with those generators. While not recommended, there are niche cases where a developer will want to do such a thing.
Requested remedy:
The public documentation for the affected variables should be updated, noting that those generators only officially support a subset of compilers, so the variable gets overridden.
Additionally, there are code comments in CMakeDetermine<Lang>Compiler.cmake
and CMakeDetermineCompiler.cmake
which are no longer correct and need updating to reflect what the code currently does.