diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2023-10-28 02:43:37 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-11-01 13:52:08 (GMT) |
commit | 889aa0354aa533dce0e96334401267aa30bff215 (patch) | |
tree | 1e6772eb7c07feddd9b1ae0fabcf34c23b08899b /Source/cmGeneratorTarget.cxx | |
parent | e3747a2d4be427e97af01ca1cce1c6641d4dff74 (diff) | |
download | CMake-889aa0354aa533dce0e96334401267aa30bff215.zip CMake-889aa0354aa533dce0e96334401267aa30bff215.tar.gz CMake-889aa0354aa533dce0e96334401267aa30bff215.tar.bz2 |
CMP0155: ignore scanning for sources if no scanner is available
This allows for a more graceful transition for projects using C++20
without scanner support (e.g., Clang 15 or GCC 13). While newer
compilers will (needlessly) scan, it allows C++20-using projects to use
older compilers without having to set `CMAKE_CXX_SCAN_FOR_MODULES` to
support newer CMake minimum versions.
Fixes: #25357
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2ea18bd..a9225dc 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -9292,14 +9292,19 @@ bool cmGeneratorTarget::NeedDyndepForSource(std::string const& lang, return true; } + bool haveRule = false; switch (this->HaveCxxModuleSupport(config)) { case Cxx20SupportLevel::MissingCxx: case Cxx20SupportLevel::NoCxx20: return false; case Cxx20SupportLevel::MissingRule: + break; case Cxx20SupportLevel::Supported: + haveRule = true; break; } + bool haveGeneratorSupport = + this->GetGlobalGenerator()->CheckCxxModuleSupport(); auto const sfProp = sf->GetProperty("CXX_SCAN_FOR_MODULES"); if (sfProp.IsSet()) { return sfProp.IsOn(); @@ -9319,8 +9324,9 @@ bool cmGeneratorTarget::NeedDyndepForSource(std::string const& lang, case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_IF_USED: case cmPolicies::NEW: - // The NEW behavior is to scan the source. - policyAnswer = true; + // The NEW behavior is to scan the source if the compiler supports + // scanning and the generator supports it. + policyAnswer = haveRule && haveGeneratorSupport; break; } return policyAnswer; |