summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-11-01 17:47:57 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-11-01 17:48:14 (GMT)
commit59c3ce4c838c0ff8614f0091033183c336f874d6 (patch)
tree5f10e551d340214d330d814ee64400f99f50739c /Source
parent8b95e3ff434948541fcbaeaa03e1137eda846abe (diff)
parent1f507580a13b2883a016cab2f18cf3d6f868d269 (diff)
downloadCMake-59c3ce4c838c0ff8614f0091033183c336f874d6.zip
CMake-59c3ce4c838c0ff8614f0091033183c336f874d6.tar.gz
CMake-59c3ce4c838c0ff8614f0091033183c336f874d6.tar.bz2
Merge topic 'cxxmodules-cmp0155-graceful-fallback-without-scanner' into release-3.28
1f507580a1 cmGlobalGenerator: give context about module queries 889aa0354a CMP0155: ignore scanning for sources if no scanner is available Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Merge-request: !8925
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorTarget.cxx17
-rw-r--r--Source/cmGlobalGenerator.h12
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx5
-rw-r--r--Source/cmGlobalNinjaGenerator.h2
-rw-r--r--Source/cmGlobalVisualStudioVersionedGenerator.h2
-rw-r--r--Source/cmPolicies.h8
6 files changed, 33 insertions, 13 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 2ea18bd..f224ec1 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -9190,7 +9190,8 @@ void cmGeneratorTarget::CheckCxxModuleStatus(std::string const& config) const
// If the generator doesn't support modules at all, error that we have
// sources that require the support.
- if (!this->GetGlobalGenerator()->CheckCxxModuleSupport()) {
+ if (!this->GetGlobalGenerator()->CheckCxxModuleSupport(
+ cmGlobalGenerator::CxxModuleSupportQuery::Expected)) {
this->Makefile->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat(
@@ -9248,7 +9249,8 @@ bool cmGeneratorTarget::NeedCxxModuleSupport(std::string const& lang,
return false;
}
return this->HaveCxxModuleSupport(config) == Cxx20SupportLevel::Supported &&
- this->GetGlobalGenerator()->CheckCxxModuleSupport();
+ this->GetGlobalGenerator()->CheckCxxModuleSupport(
+ cmGlobalGenerator::CxxModuleSupportQuery::Inspect);
}
bool cmGeneratorTarget::NeedDyndep(std::string const& lang,
@@ -9292,14 +9294,20 @@ 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(
+ cmGlobalGenerator::CxxModuleSupportQuery::Inspect);
auto const sfProp = sf->GetProperty("CXX_SCAN_FOR_MODULES");
if (sfProp.IsSet()) {
return sfProp.IsOn();
@@ -9319,8 +9327,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;
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 6d29dc1..aa54f69 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -156,7 +156,17 @@ public:
virtual bool InspectConfigTypeVariables() { return true; }
- virtual bool CheckCxxModuleSupport() { return false; }
+ enum class CxxModuleSupportQuery
+ {
+ // Support is expected at the call site.
+ Expected,
+ // The call site is querying for support and handles problems by itself.
+ Inspect,
+ };
+ virtual bool CheckCxxModuleSupport(CxxModuleSupportQuery /*query*/)
+ {
+ return false;
+ }
virtual bool IsGNUMakeJobServerAware() const { return false; }
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 7368a6a..d691d88 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -882,13 +882,14 @@ bool cmGlobalNinjaGenerator::CheckLanguages(
return true;
}
-bool cmGlobalNinjaGenerator::CheckCxxModuleSupport()
+bool cmGlobalNinjaGenerator::CheckCxxModuleSupport(CxxModuleSupportQuery query)
{
if (this->NinjaSupportsDyndepsCxx) {
return true;
}
bool const diagnose = !this->DiagnosedCxxModuleNinjaSupport &&
- !this->CMakeInstance->GetIsInTryCompile();
+ !this->CMakeInstance->GetIsInTryCompile() &&
+ query == CxxModuleSupportQuery::Expected;
if (diagnose) {
std::ostringstream e;
/* clang-format off */
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 56a922c..c5d6901 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -475,7 +475,7 @@ public:
bool IsSingleConfigUtility(cmGeneratorTarget const* target) const;
- bool CheckCxxModuleSupport() override;
+ bool CheckCxxModuleSupport(CxxModuleSupportQuery query) override;
protected:
void Generate() override;
diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.h b/Source/cmGlobalVisualStudioVersionedGenerator.h
index 8f0345f..49643ea 100644
--- a/Source/cmGlobalVisualStudioVersionedGenerator.h
+++ b/Source/cmGlobalVisualStudioVersionedGenerator.h
@@ -48,7 +48,7 @@ public:
const char* GetAndroidApplicationTypeRevision() const override;
- bool CheckCxxModuleSupport() override
+ bool CheckCxxModuleSupport(CxxModuleSupportQuery /*query*/) override
{
return this->SupportsCxxModuleDyndep();
}
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 1ea2ce2..8838de4 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -470,10 +470,10 @@ class cmMakefile;
POLICY, CMP0154, \
"Generated files are private by default in targets using file sets.", 3, \
28, 0, cmPolicies::WARN) \
- SELECT( \
- POLICY, CMP0155, \
- "C++ sources in targets with at least C++20 are scanned for imports", 3, \
- 28, 0, cmPolicies::WARN)
+ SELECT(POLICY, CMP0155, \
+ "C++ sources in targets with at least C++20 are scanned for " \
+ "imports when supported.", \
+ 3, 28, 0, cmPolicies::WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
#define CM_FOR_EACH_POLICY_ID(POLICY) \