mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-22 22:31:18 -05:00
Merge topic 'cxxmodules-cmp0155-graceful-fallback-without-scanner'
1f507580a1cmGlobalGenerator: give context about module queries889aa0354aCMP0155: 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
This commit is contained in:
@@ -9259,7 +9259,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(
|
||||
@@ -9317,7 +9318,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,
|
||||
@@ -9361,14 +9363,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();
|
||||
@@ -9388,8 +9396,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;
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -475,7 +475,7 @@ public:
|
||||
|
||||
bool IsSingleConfigUtility(cmGeneratorTarget const* target) const;
|
||||
|
||||
bool CheckCxxModuleSupport() override;
|
||||
bool CheckCxxModuleSupport(CxxModuleSupportQuery query) override;
|
||||
|
||||
protected:
|
||||
void Generate() override;
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
|
||||
const char* GetAndroidApplicationTypeRevision() const override;
|
||||
|
||||
bool CheckCxxModuleSupport() override
|
||||
bool CheckCxxModuleSupport(CxxModuleSupportQuery /*query*/) override
|
||||
{
|
||||
return this->SupportsCxxModuleDyndep();
|
||||
}
|
||||
|
||||
+4
-4
@@ -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) \
|
||||
|
||||
Reference in New Issue
Block a user