From 0247a495c1ec8855ca70557c39af47b12c9ed7ec Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 30 Jul 2008 11:06:11 -0400 Subject: 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. --- Source/cmSourceFileLocation.cxx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx index 6388977..d7b2aa6 100644 --- a/Source/cmSourceFileLocation.cxx +++ b/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& srcExts = mf->GetSourceExtensions(); const std::vector& 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. -- cgit v0.12