cmGlobalGenerator: factor out C++ module support checking

This will simplify adding support to other generators.
This commit is contained in:
Ben Boeckel
2022-11-23 15:21:59 -05:00
parent 9b9a421668
commit 5e026739e1
4 changed files with 27 additions and 12 deletions

View File

@@ -1439,6 +1439,19 @@ bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const
return false;
}
void cmGlobalGenerator::CxxModuleSupportCheck() const
{
bool const diagnose = !this->DiagnosedCxxModuleSupport &&
!this->CMakeInstance->GetIsInTryCompile();
if (diagnose) {
this->DiagnosedCxxModuleSupport = true;
this->GetCMakeInstance()->IssueMessage(
MessageType::AUTHOR_WARNING,
"C++20 modules support via CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP "
"is experimental. It is meant only for compiler developers to try.");
}
}
void cmGlobalGenerator::ComputeBuildFileGenerators()
{
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
@@ -1597,6 +1610,8 @@ void cmGlobalGenerator::Generate()
// it builds by default.
this->InitializeProgressMarks();
this->DiagnosedCxxModuleSupport = false;
this->ProcessEvaluationFiles();
this->CMakeInstance->UpdateProgress("Generating", 0.1f);

View File

@@ -157,6 +157,8 @@ public:
virtual bool InspectConfigTypeVariables() { return true; }
virtual bool CheckCxxModuleSupport() { return false; }
bool Compute();
virtual void AddExtraIDETargets() {}
@@ -621,6 +623,8 @@ protected:
virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const;
void CxxModuleSupportCheck() const;
/// @brief Qt AUTOMOC/UIC/RCC target generation
/// @return true on success
bool QtAutoGen();
@@ -728,6 +732,8 @@ private:
std::map<std::string, int> LanguageToLinkerPreference;
std::map<std::string, std::string> LanguageToOriginalSharedLibFlags;
mutable bool DiagnosedCxxModuleSupport = false;
// Deferral id generation.
size_t NextDeferId = 0;

View File

@@ -591,7 +591,7 @@ void cmGlobalNinjaGenerator::Generate()
this->TargetAll = this->NinjaOutputPath("all");
this->CMakeCacheFile = this->NinjaOutputPath("CMakeCache.txt");
this->DisableCleandead = false;
this->DiagnosedCxxModuleSupport = false;
this->DiagnosedCxxModuleNinjaSupport = false;
this->PolicyCMP0058 =
this->LocalGenerators[0]->GetMakefile()->GetPolicyStatus(
@@ -850,18 +850,12 @@ bool cmGlobalNinjaGenerator::CheckLanguages(
bool cmGlobalNinjaGenerator::CheckCxxModuleSupport()
{
bool const diagnose = !this->DiagnosedCxxModuleSupport &&
!this->CMakeInstance->GetIsInTryCompile();
if (diagnose) {
this->DiagnosedCxxModuleSupport = true;
this->GetCMakeInstance()->IssueMessage(
MessageType::AUTHOR_WARNING,
"C++20 modules support via CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP "
"is experimental. It is meant only for compiler developers to try.");
}
this->CxxModuleSupportCheck();
if (this->NinjaSupportsDyndeps) {
return true;
}
bool const diagnose = !this->DiagnosedCxxModuleNinjaSupport &&
!this->CMakeInstance->GetIsInTryCompile();
if (diagnose) {
std::ostringstream e;
/* clang-format off */

View File

@@ -469,7 +469,7 @@ public:
bool IsSingleConfigUtility(cmGeneratorTarget const* target) const;
bool CheckCxxModuleSupport();
bool CheckCxxModuleSupport() override;
protected:
void Generate() override;
@@ -592,7 +592,7 @@ private:
codecvt::Encoding NinjaExpectedEncoding = codecvt::None;
bool DiagnosedCxxModuleSupport = false;
bool DiagnosedCxxModuleNinjaSupport = false;
void InitOutputPathPrefix();