Ninja: Add compile rules only for languages that are actually compiled
In `WriteLanguageRules` we collect all languages used for source files in a target. However, this only needs to include sources that are actually going to be compiled into object files. No object file build statements will be generated for other sources. This avoids generating language compile rules for source files that are not compiled due to being marked as `HEADER_FILE_ONLY`. Issue: #16373
This commit is contained in:
parent
96f6fe6b57
commit
3a9e92bce1
@ -106,10 +106,11 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules()
|
||||
|
||||
// Write rules for languages compiled in this target.
|
||||
std::set<std::string> languages;
|
||||
std::vector<cmSourceFile*> sourceFiles;
|
||||
this->GetGeneratorTarget()->GetSourceFiles(
|
||||
std::vector<cmSourceFile const*> sourceFiles;
|
||||
this->GetGeneratorTarget()->GetObjectSources(
|
||||
sourceFiles, this->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"));
|
||||
for (std::vector<cmSourceFile*>::const_iterator i = sourceFiles.begin();
|
||||
for (std::vector<cmSourceFile const*>::const_iterator i =
|
||||
sourceFiles.begin();
|
||||
i != sourceFiles.end(); ++i) {
|
||||
const std::string& lang = (*i)->GetLanguage();
|
||||
if (!lang.empty()) {
|
||||
|
Loading…
Reference in New Issue
Block a user