From 5e7c8f44ac7d0157d234544e7ec903910985a0fa Mon Sep 17 00:00:00 2001 From: Lingkai Dong Date: Thu, 10 Nov 2022 14:56:18 +0000 Subject: Ninja: Restore support for compilers not defining a C++ standard level Since commit 386465bf83 (cmTarget: add support for C++ module fileset types, 2022-04-08, v3.25.0-rc1~624^2~7), the Ninja generator checks for C++20 support using logic that requires `CMAKE__STANDARD_DEFAULT` to be non-empty. On some compilers, such as ARMClang, CMake does not automatically detect and set default language standards, thus causing `HaveStandardAvailable` to raise an internal error. To fix this issue, if `CMAKE_CXX_STANDARD_DEFAULT` is empty, assume all standards to be supported instead of calling `HaveStandardAvailable`. This is consistent with how `CompileFeaturesNode::Evaluate` handles this case. Fixes: #24146 --- Source/cmGeneratorTarget.cxx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'Source/cmGeneratorTarget.cxx') diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6195d1ff07..7d43eb139f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -8798,11 +8798,18 @@ cmGeneratorTarget::Cxx20SupportLevel cmGeneratorTarget::HaveCxxModuleSupport( if (!state->GetLanguageEnabled("CXX")) { return Cxx20SupportLevel::MissingCxx; } - cmStandardLevelResolver standardResolver(this->Makefile); - if (!standardResolver.HaveStandardAvailable(this, "CXX", config, - "cxx_std_20")) { - return Cxx20SupportLevel::NoCxx20; - } + cmValue standardDefault = + this->Target->GetMakefile()->GetDefinition("CMAKE_CXX_STANDARD_DEFAULT"); + if (standardDefault && !standardDefault->empty()) { + cmStandardLevelResolver standardResolver(this->Makefile); + if (!standardResolver.HaveStandardAvailable(this, "CXX", config, + "cxx_std_20")) { + return Cxx20SupportLevel::NoCxx20; + } + } + // Else, an empty CMAKE_CXX_STANDARD_DEFAULT means CMake does not detect and + // set a default standard level for this compiler, so assume all standards + // are available. if (!this->Makefile->IsOn("CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP")) { return Cxx20SupportLevel::MissingExperimentalFlag; } -- cgit v1.2.1