From 3cddd116495a85ce86e1149c05ce9a2a701e0c8b Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 28 Sep 2023 16:08:06 -0400 Subject: Ninja: message about not compiled sources explicitly With CMP0155, filesets with only non-compiled sources do not go through the collation path that detects it. Detect it explicitly like the Visual Studio generator does. --- Source/cmNinjaTargetGenerator.cxx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 5d4397b..0bda945 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1143,6 +1143,30 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements( } } + // Detect sources in `CXX_MODULES` which are not compiled. + { + std::vector sources; + this->GeneratorTarget->GetSourceFiles(sources, config); + for (cmSourceFile const* sf : sources) { + cmFileSet const* fs = + this->GeneratorTarget->GetFileSetForSource(config, sf); + if (!fs) { + continue; + } + if (fs->GetType() != "CXX_MODULES"_s) { + continue; + } + if (sf->GetLanguage().empty()) { + this->GeneratorTarget->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Target \"", this->GeneratorTarget->GetName(), + "\" has source file\n ", sf->GetFullPath(), + "\nin a \"FILE_SET TYPE CXX_MODULES\" but it is not " + "scheduled for compilation.")); + } + } + } + for (auto const& langScanningFiles : this->Configs[config].ScanningInfo) { std::string const& language = langScanningFiles.first; std::vector const& scanningFiles = langScanningFiles.second; -- cgit v0.12