ソースを参照

ENH: Recognize src extensions of all enabled langs

For historical reasons we still support naming of source files without
their extension.  Sources without known extensions are located on disk
by iterating through a fixed set of possible extensions.  We now want
users to always specify the extension, so the fixed set will not be
expanded and is preserved for compatibility with older projects.

This change adds recognition of extensions of all enabled languages to
avoid checking the disk for files whose extensions are unambiguous but
not in the original fixed set.
Brad King 17 年 前
コミット
0247a495c1
1 ファイル変更8 行追加3 行削除
  1. 8 3
      Source/cmSourceFileLocation.cxx

+ 8 - 3
Source/cmSourceFileLocation.cxx

@@ -17,6 +17,8 @@
 #include "cmSourceFileLocation.h"
 
 #include "cmMakefile.h"
+#include "cmLocalGenerator.h"
+#include "cmGlobalGenerator.h"
 #include "cmSystemTools.h"
 
 //----------------------------------------------------------------------------
@@ -89,11 +91,14 @@ void cmSourceFileLocation::UpdateExtension(const char* name)
   std::string ext = cmSystemTools::GetFilenameLastExtension(name);
   if(!ext.empty()) { ext = ext.substr(1); }
 
-  // TODO: Let enable-language specify extensions for each language.
-  cmMakefile const* mf = this->Makefile;
+  // The global generator checks extensions of enabled languages.
+  cmGlobalGenerator* gg =
+    this->Makefile->GetLocalGenerator()->GetGlobalGenerator();
+  cmMakefile* mf = this->Makefile;
   const std::vector<std::string>& srcExts = mf->GetSourceExtensions();
   const std::vector<std::string>& hdrExts = mf->GetHeaderExtensions();
-  if(std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end() ||
+  if(gg->GetLanguageFromExtension(ext.c_str()) ||
+     std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end() ||
      std::find(hdrExts.begin(), hdrExts.end(), ext) != hdrExts.end())
     {
     // This is a known extension.  Use the given filename with extension.