浏览代码

cmExtraCodeLiteGenerator: Use cmake::Is*Extension for file type detection

In cmExtraCodeLiteGenerator.cxx use `cmake::Is*Extension` methods instead of
`cmSystemTools::GetFileFormat` for file type detection.
Sebastian Holtermann 6 年之前
父节点
当前提交
90b5289c55
共有 1 个文件被更改,包括 9 次插入10 次删除
  1. 9 10
      Source/cmExtraCodeLiteGenerator.cxx

+ 9 - 10
Source/cmExtraCodeLiteGenerator.cxx

@@ -217,22 +217,21 @@ std::string cmExtraCodeLiteGenerator::CollectSourceFiles(
     case cmStateEnums::STATIC_LIBRARY:
     case cmStateEnums::STATIC_LIBRARY:
     case cmStateEnums::SHARED_LIBRARY:
     case cmStateEnums::SHARED_LIBRARY:
     case cmStateEnums::MODULE_LIBRARY: {
     case cmStateEnums::MODULE_LIBRARY: {
+      cmake const* cm = makefile->GetCMakeInstance();
       std::vector<cmSourceFile*> sources;
       std::vector<cmSourceFile*> sources;
       gt->GetSourceFiles(sources,
       gt->GetSourceFiles(sources,
                          makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
                          makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
       for (cmSourceFile* s : sources) {
       for (cmSourceFile* s : sources) {
+        std::string const& fullPath = s->GetFullPath();
+        std::string const& extLower =
+          cmSystemTools::LowerCase(s->GetExtension());
         // check whether it is a source or a include file
         // check whether it is a source or a include file
         // then put it accordingly into one of the two containers
         // then put it accordingly into one of the two containers
-        switch (cmSystemTools::GetFileFormat(s->GetExtension())) {
-          case cmSystemTools::C_FILE_FORMAT:
-          case cmSystemTools::CXX_FILE_FORMAT:
-          case cmSystemTools::CUDA_FILE_FORMAT:
-          case cmSystemTools::FORTRAN_FILE_FORMAT: {
-            cFiles[s->GetFullPath()] = s;
-          } break;
-          default: {
-            otherFiles.insert(s->GetFullPath());
-          }
+        if (cm->IsSourceExtension(extLower) || cm->IsCudaExtension(extLower) ||
+            cm->IsFortranExtension(extLower)) {
+          cFiles[fullPath] = s;
+        } else {
+          otherFiles.insert(fullPath);
         }
         }
       }
       }
     }
     }