summaryrefslogtreecommitdiffstats
path: root/Source/cmSourceFileLocation.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-07-30 15:06:11 (GMT)
committerBrad King <brad.king@kitware.com>2008-07-30 15:06:11 (GMT)
commit0247a495c1ec8855ca70557c39af47b12c9ed7ec (patch)
treed050313824feb7dcbd3222597143f47661b4406f /Source/cmSourceFileLocation.cxx
parent24c9434a81862a7d901a685f5d6df206fe7e612f (diff)
downloadCMake-0247a495c1ec8855ca70557c39af47b12c9ed7ec.zip
CMake-0247a495c1ec8855ca70557c39af47b12c9ed7ec.tar.gz
CMake-0247a495c1ec8855ca70557c39af47b12c9ed7ec.tar.bz2
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.
Diffstat (limited to 'Source/cmSourceFileLocation.cxx')
-rw-r--r--Source/cmSourceFileLocation.cxx11
1 files 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<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.