Commit 0247a495 authored by Brad King's avatar Brad King

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.
parent 24c9434a
......@@ -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 =
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.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment