From 3a9e92bce1c10e0082d431a61e100485fd6cf270 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 18 Oct 2016 15:35:10 -0400 Subject: 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 --- Source/cmNinjaNormalTargetGenerator.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index b28b19af94..80d6d93c03 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -106,10 +106,11 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules() // Write rules for languages compiled in this target. std::set languages; - std::vector sourceFiles; - this->GetGeneratorTarget()->GetSourceFiles( + std::vector sourceFiles; + this->GetGeneratorTarget()->GetObjectSources( sourceFiles, this->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE")); - for (std::vector::const_iterator i = sourceFiles.begin(); + for (std::vector::const_iterator i = + sourceFiles.begin(); i != sourceFiles.end(); ++i) { const std::string& lang = (*i)->GetLanguage(); if (!lang.empty()) { -- cgit v1.2.1