mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
cmGlobalGenerator: give context about module queries
Some queries are merely investigating support in order to change behavior. Let the method know so that any internal errors can be skipped over.
This commit is contained in:
@@ -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,
|
||||
@@ -9304,7 +9306,8 @@ bool cmGeneratorTarget::NeedDyndepForSource(std::string const& lang,
|
||||
break;
|
||||
}
|
||||
bool haveGeneratorSupport =
|
||||
this->GetGlobalGenerator()->CheckCxxModuleSupport();
|
||||
this->GetGlobalGenerator()->CheckCxxModuleSupport(
|
||||
cmGlobalGenerator::CxxModuleSupportQuery::Inspect);
|
||||
auto const sfProp = sf->GetProperty("CXX_SCAN_FOR_MODULES");
|
||||
if (sfProp.IsSet()) {
|
||||
return sfProp.IsOn();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user