MSVC variable documentation is inaccurate
CMake docs claim that MSVC
is "[set] to true when the compiler is some version of Microsoft Visual C++ or another compiler simulating Visual C++. Any compiler defining _MSC_VER
is considered simulating Visual C++. See also the MSVC_VERSION
variable."
This is contradicted by the observed behaviour when using clang (as opposed to clang-cl) as your CMAKE_{C,CXX}_COMPILER
on Windows. In this situation, _MSC_VER
is defined by the compiler, yet CMake does not set MSVC
. CMake does, however, set MSVC_VERSION
.
I'm assuming that the observed behaviour is correct and the docs are wrong -- it's common to see if(MSVC)
in CMake scripts used to conditionally add cl.exe-style arguments.
Tested under CMake 3.19.2.