diff options
author | Brad King <brad.king@kitware.com> | 2023-10-03 21:21:00 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-10-03 21:21:18 (GMT) |
commit | 89a065613d00d4e5c951deefbe5e4a36a08b0950 (patch) | |
tree | 57a1189347a336391927253037a2cd28b67ede9f /Source | |
parent | debfb09e49efcb51a15f58b6dc81e9e9ec9b12ee (diff) | |
parent | 7ac696549a8608490e871ee77efe4086daf28add (diff) | |
download | CMake-89a065613d00d4e5c951deefbe5e4a36a08b0950.zip CMake-89a065613d00d4e5c951deefbe5e4a36a08b0950.tar.gz CMake-89a065613d00d4e5c951deefbe5e4a36a08b0950.tar.bz2 |
Merge topic 'cxxmodules-verify-c++20'
7ac696549a cxxmodules: Fix CMP0155 NEW behavior when C++ compile features are not known
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !8857
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 96fcf7e..422d927 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -9093,20 +9093,27 @@ cmGeneratorTarget::Cxx20SupportLevel cmGeneratorTarget::HaveCxxModuleSupport( if (!state->GetLanguageEnabled("CXX")) { return Cxx20SupportLevel::MissingCxx; } + 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; - } + this->Makefile->GetDefinition("CMAKE_CXX_STANDARD_DEFAULT"); + if (!standardDefault || standardDefault->empty()) { + // We do not know any meaningful C++ standard levels for this compiler. + return Cxx20SupportLevel::NoCxx20; + } + + 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()) { + 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. + cmValue scandepRule = - this->Target->GetMakefile()->GetDefinition("CMAKE_CXX_SCANDEP_SOURCE"); + this->Makefile->GetDefinition("CMAKE_CXX_SCANDEP_SOURCE"); if (!scandepRule) { return Cxx20SupportLevel::MissingRule; } |