| 6208 | } |
| 6209 | |
| 6210 | void cmGeneratorTarget::CheckCxxModuleStatus(std::string const& config) const |
| 6211 | { |
| 6212 | bool haveScannableSources = false; |
| 6213 | |
| 6214 | // Check for `CXX_MODULE*` file sets and a lack of support. |
| 6215 | if (this->HaveCxx20ModuleSources()) { |
| 6216 | haveScannableSources = true; |
| 6217 | } |
| 6218 | |
| 6219 | if (!haveScannableSources) { |
| 6220 | // Check to see if there are regular sources that have requested scanning. |
| 6221 | auto sources = this->GetSourceFiles(config); |
| 6222 | for (auto const& source : sources) { |
| 6223 | auto const* sf = source.Value; |
| 6224 | auto const& lang = sf->GetLanguage(); |
| 6225 | if (lang != "CXX"_s) { |
| 6226 | continue; |
| 6227 | } |
| 6228 | // Ignore sources which do not need dyndep. |
| 6229 | if (this->NeedDyndepForSource(lang, config, sf)) { |
| 6230 | haveScannableSources = true; |
| 6231 | } |
| 6232 | } |
| 6233 | } |
| 6234 | |
| 6235 | // If there isn't anything scannable, ignore it. |
| 6236 | if (!haveScannableSources) { |
| 6237 | return; |
| 6238 | } |
| 6239 | |
| 6240 | // If the generator doesn't support modules at all, error that we have |
| 6241 | // sources that require the support. |
| 6242 | if (!this->GetGlobalGenerator()->CheckCxxModuleSupport( |
| 6243 | cmGlobalGenerator::CxxModuleSupportQuery::Expected)) { |
| 6244 | this->Makefile->IssueMessage( |
| 6245 | MessageType::FATAL_ERROR, |
| 6246 | cmStrCat("The target named \"", this->GetName(), |
| 6247 | "\" has C++ sources that may use modules, but modules are not " |
| 6248 | "supported by this generator:\n ", |
| 6249 | this->GetGlobalGenerator()->GetName(), |
| 6250 | "\n" |
| 6251 | "Modules are supported only by Ninja, Ninja Multi-Config, " |
| 6252 | "and Visual Studio generators for VS 17.4 and newer. " |
| 6253 | "See the cmake-cxxmodules(7) manual for details. " |
| 6254 | "Use the CMAKE_CXX_SCAN_FOR_MODULES variable to enable or " |
| 6255 | "disable scanning.")); |
| 6256 | return; |
| 6257 | } |
| 6258 | |
| 6259 | switch (this->HaveCxxModuleSupport(config)) { |
| 6260 | case cmGeneratorTarget::Cxx20SupportLevel::MissingCxx: |
| 6261 | this->Makefile->IssueMessage( |
| 6262 | MessageType::FATAL_ERROR, |
| 6263 | cmStrCat("The target named \"", this->GetName(), |
| 6264 | "\" has C++ sources that use modules, but the \"CXX\" " |
| 6265 | "language has not been enabled.")); |
| 6266 | break; |
| 6267 | case cmGeneratorTarget::Cxx20SupportLevel::NoCxx20: { |
no test coverage detected