It appears that doing (say) set(CMAKE_CXX_STANDARD 17)
when targeting MSVC will set the /std:c++17
flag, but not (also) the MS-specific /Zc:__cplusplus
flag; this is unfortunate, because MSVC explicitly sets __cplusplus
to 199711L in all cases when /Zc:cplusplus
is unspecified. (See https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/).
While this is arguably a bad decision on the part of MSVC, CMake should just quietly work around it by setting both of these flags, to ensure __cplusplus has an accurate value.