Browse Source

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
Brad King 9 years ago
parent
commit
3a9e92bce1
1 changed files with 4 additions and 3 deletions
  1. 4 3
      Source/cmNinjaNormalTargetGenerator.cxx

+ 4 - 3
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()) {