summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2022-11-23 20:21:59 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2022-11-23 22:31:31 (GMT)
commit5e026739e10f4cf5241f27fb9ba6721edb854018 (patch)
tree9d7ef765c1ad70d2957d159962bba3b23de835bf
parent9b9a42166803e864a8b08c22cadfe8db447acb40 (diff)
downloadCMake-5e026739e10f4cf5241f27fb9ba6721edb854018.zip
CMake-5e026739e10f4cf5241f27fb9ba6721edb854018.tar.gz
CMake-5e026739e10f4cf5241f27fb9ba6721edb854018.tar.bz2
cmGlobalGenerator: factor out C++ module support checking
This will simplify adding support to other generators.
-rw-r--r--Source/cmGlobalGenerator.cxx15
-rw-r--r--Source/cmGlobalGenerator.h6
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx14
-rw-r--r--Source/cmGlobalNinjaGenerator.h4
4 files changed, 27 insertions, 12 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index a9485b5..8ca6ee6 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -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);
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 89b2ea8..4ebf9f6 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -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;
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index e334666..618dfb7 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -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 */
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 1628349..6f654f6 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -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();