cxxmodules: Scan only targets that explicitly enable C++ 20

Previously we scanned any targets for which C++ 20 is enabled,
even if enabled only by the compiler's default, such as when
`CXXFLAGS=-std=c++20`.
This commit is contained in:
Brad King
2023-10-04 15:48:36 -04:00
parent 68fca3eafe
commit b8ead378de
4 changed files with 23 additions and 7 deletions
+5 -7
View File
@@ -9142,13 +9142,11 @@ cmGeneratorTarget::Cxx20SupportLevel cmGeneratorTarget::HaveCxxModuleSupport(
}
cmStandardLevelResolver standardResolver(this->Makefile);
if (!standardResolver.HaveStandardAvailable(this, "CXX", config,
"cxx_std_20") ||
// During the ABI detection step we do not know the compiler's features.
// HaveStandardAvailable may return true as a fallback, but in this code
// path we do not want to assume C++ 20 is available.
this->Makefile->GetDefinition("CMAKE_CXX20_COMPILE_FEATURES")
.IsEmpty()) {
cmStandardLevel const cxxStd20 =
*standardResolver.LanguageStandardLevel("CXX", "20");
cm::optional<cmStandardLevel> explicitLevel =
this->GetExplicitStandardLevel("CXX", config);
if (!explicitLevel || *explicitLevel < cxxStd20) {
return Cxx20SupportLevel::NoCxx20;
}