cxxmodules: Fix CMP0155 NEW behavior when C++ compile features are not known
With CMP0155 NEW behavior, we scan C++ sources in targets using C++ 20,
i.e., in which the cxx_std_20
feature is available. However, our
check for C++ feature availability may incorrectly succeed in two cases:
-
MSVC versions from VS 2013 do not model C++ standard levels, so we assume all features are available as a heuristic to let projects at least try compiling with them.
-
During ABI detection the
CMAKE_CXX20_COMPILE_FEATURES
variable is not populated so we assume all features are available, knowing that our ABI detection project does not need them.
For purposes of detecting targets using C++ 20, we do not want to assume
cxx_std_20
is available, so verify that we really know it is.
For reference, this bug was exposed by commit 8bd2c8d1.
Backport: release
Topic-rename: cxxmodules-verify-c++20