summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-10-18 15:35:10 -0400
committerBrad King <brad.king@kitware.com>2016-10-18 15:35:10 -0400
commit3a9e92bce1c10e0082d431a61e100485fd6cf270 (patch)
treeb2dc2e604a1f4745d748ba04ed7aedea16cb8e44
parent96f6fe6b5737494fc560e126b7c797d232d9307e (diff)
downloadcmake-3a9e92bce1c10e0082d431a61e100485fd6cf270.tar.gz
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
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx7
1 files 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<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()) {