cmake: Store hardcoded lists of sources and headers
Don't duplicate this in each cmMakefile.
This commit is contained in:
parent
6bd7bd1e06
commit
780bff5279
|
@ -60,10 +60,10 @@ bool cmAuxSourceDirectoryCommand::InitialPass
|
|||
std::string ext = file.substr(dotpos+1);
|
||||
std::string base = file.substr(0, dotpos);
|
||||
// Process only source files
|
||||
if(!base.empty()
|
||||
&& std::find( this->Makefile->GetSourceExtensions().begin(),
|
||||
this->Makefile->GetSourceExtensions().end(), ext )
|
||||
!= this->Makefile->GetSourceExtensions().end() )
|
||||
std::vector<std::string> srcExts =
|
||||
this->Makefile->GetCMakeInstance()->GetSourceExtensions();
|
||||
if(!base.empty() &&
|
||||
std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end())
|
||||
{
|
||||
std::string fullname = templateDirectory;
|
||||
fullname += "/";
|
||||
|
|
|
@ -383,6 +383,9 @@ void cmExtraCodeBlocksGenerator
|
|||
all_files_map_t allFiles;
|
||||
std::vector<std::string> cFiles;
|
||||
|
||||
std::vector<std::string> srcExts =
|
||||
this->GlobalGenerator->GetCMakeInstance()->GetSourceExtensions();
|
||||
|
||||
for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
|
||||
lg!=lgs.end(); lg++)
|
||||
{
|
||||
|
@ -420,9 +423,7 @@ void cmExtraCodeBlocksGenerator
|
|||
{
|
||||
std::string srcext = (*si)->GetExtension();
|
||||
for(std::vector<std::string>::const_iterator
|
||||
ext = mf->GetSourceExtensions().begin();
|
||||
ext != mf->GetSourceExtensions().end();
|
||||
++ext)
|
||||
ext = srcExts.begin(); ext != srcExts.end(); ++ext)
|
||||
{
|
||||
if (srcext == *ext)
|
||||
{
|
||||
|
@ -449,6 +450,9 @@ void cmExtraCodeBlocksGenerator
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> headerExts =
|
||||
this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions();
|
||||
|
||||
// The following loop tries to add header files matching to implementation
|
||||
// files to the project. It does that by iterating over all
|
||||
// C/C++ source files,
|
||||
|
@ -468,8 +472,8 @@ void cmExtraCodeBlocksGenerator
|
|||
|
||||
// check if there's a matching header around
|
||||
for(std::vector<std::string>::const_iterator
|
||||
ext = mf->GetHeaderExtensions().begin();
|
||||
ext != mf->GetHeaderExtensions().end();
|
||||
ext = headerExts.begin();
|
||||
ext != headerExts.end();
|
||||
++ext)
|
||||
{
|
||||
std::string hname=headerBasename;
|
||||
|
|
|
@ -149,6 +149,11 @@ void cmExtraCodeLiteGenerator
|
|||
// which may have an acompanying header, one for all other files
|
||||
std::string projectType;
|
||||
|
||||
std::vector<std::string> srcExts =
|
||||
this->GlobalGenerator->GetCMakeInstance()->GetSourceExtensions();
|
||||
std::vector<std::string> headerExts =
|
||||
this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions();
|
||||
|
||||
std::map<std::string, cmSourceFile*> cFiles;
|
||||
std::set<std::string> otherFiles;
|
||||
for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
|
||||
|
@ -207,9 +212,7 @@ void cmExtraCodeLiteGenerator
|
|||
{
|
||||
std::string srcext = (*si)->GetExtension();
|
||||
for(std::vector<std::string>::const_iterator
|
||||
ext = mf->GetSourceExtensions().begin();
|
||||
ext != mf->GetSourceExtensions().end();
|
||||
++ext)
|
||||
ext = srcExts.begin(); ext != srcExts.end(); ++ext)
|
||||
{
|
||||
if (srcext == *ext)
|
||||
{
|
||||
|
@ -253,8 +256,8 @@ void cmExtraCodeLiteGenerator
|
|||
|
||||
// check if there's a matching header around
|
||||
for(std::vector<std::string>::const_iterator
|
||||
ext = mf->GetHeaderExtensions().begin();
|
||||
ext != mf->GetHeaderExtensions().end();
|
||||
ext = headerExts.begin();
|
||||
ext != headerExts.end();
|
||||
++ext)
|
||||
{
|
||||
std::string hname=headerBasename;
|
||||
|
|
|
@ -105,6 +105,9 @@ bool cmGlobalKdevelopGenerator
|
|||
std::set<std::string> files;
|
||||
std::string tmp;
|
||||
|
||||
std::vector<std::string> hdrExts =
|
||||
this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions();
|
||||
|
||||
for (std::vector<cmLocalGenerator*>::const_iterator it=lgs.begin();
|
||||
it!=lgs.end(); it++)
|
||||
{
|
||||
|
@ -160,8 +163,7 @@ bool cmGlobalKdevelopGenerator
|
|||
|
||||
// check if there's a matching header around
|
||||
for(std::vector<std::string>::const_iterator
|
||||
ext = makefile->GetHeaderExtensions().begin();
|
||||
ext != makefile->GetHeaderExtensions().end(); ++ext)
|
||||
ext = hdrExts.begin(); ext != hdrExts.end(); ++ext)
|
||||
{
|
||||
std::string hname=headerBasename;
|
||||
hname += ".";
|
||||
|
|
|
@ -1420,7 +1420,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt)
|
|||
bool cmGlobalXCodeGenerator::IsHeaderFile(cmSourceFile* sf)
|
||||
{
|
||||
const std::vector<std::string>& hdrExts =
|
||||
this->CurrentMakefile->GetHeaderExtensions();
|
||||
this->CMakeInstance->GetHeaderExtensions();
|
||||
return (std::find(hdrExts.begin(), hdrExts.end(), sf->GetExtension()) !=
|
||||
hdrExts.end());
|
||||
}
|
||||
|
|
|
@ -57,31 +57,6 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
|
|||
|
||||
// Setup the default include complaint regular expression (match nothing).
|
||||
this->ComplainFileRegularExpression = "^$";
|
||||
// Source and header file extensions that we can handle
|
||||
|
||||
// Set up a list of source and header extensions
|
||||
// these are used to find files when the extension
|
||||
// is not given
|
||||
// The "c" extension MUST precede the "C" extension.
|
||||
this->SourceFileExtensions.push_back( "c" );
|
||||
this->SourceFileExtensions.push_back( "C" );
|
||||
|
||||
this->SourceFileExtensions.push_back( "c++" );
|
||||
this->SourceFileExtensions.push_back( "cc" );
|
||||
this->SourceFileExtensions.push_back( "cpp" );
|
||||
this->SourceFileExtensions.push_back( "cxx" );
|
||||
this->SourceFileExtensions.push_back( "m" );
|
||||
this->SourceFileExtensions.push_back( "M" );
|
||||
this->SourceFileExtensions.push_back( "mm" );
|
||||
|
||||
this->HeaderFileExtensions.push_back( "h" );
|
||||
this->HeaderFileExtensions.push_back( "hh" );
|
||||
this->HeaderFileExtensions.push_back( "h++" );
|
||||
this->HeaderFileExtensions.push_back( "hm" );
|
||||
this->HeaderFileExtensions.push_back( "hpp" );
|
||||
this->HeaderFileExtensions.push_back( "hxx" );
|
||||
this->HeaderFileExtensions.push_back( "in" );
|
||||
this->HeaderFileExtensions.push_back( "txx" );
|
||||
|
||||
this->DefineFlags = " ";
|
||||
|
||||
|
|
|
@ -425,17 +425,6 @@ public:
|
|||
cmSourceFile* GetOrCreateSource(const std::string& sourceName,
|
||||
bool generated = false);
|
||||
|
||||
//@{
|
||||
/**
|
||||
* Return a list of extensions associated with source and header
|
||||
* files
|
||||
*/
|
||||
const std::vector<std::string>& GetSourceExtensions() const
|
||||
{return this->SourceFileExtensions;}
|
||||
const std::vector<std::string>& GetHeaderExtensions() const
|
||||
{return this->HeaderFileExtensions;}
|
||||
//@}
|
||||
|
||||
/**
|
||||
* Given a variable name, return its value (as a string).
|
||||
* If the variable is not found in this makefile instance, the
|
||||
|
@ -823,8 +812,6 @@ protected:
|
|||
std::vector<cmTestGenerator*> TestGenerators;
|
||||
|
||||
std::string ComplainFileRegularExpression;
|
||||
std::vector<std::string> SourceFileExtensions;
|
||||
std::vector<std::string> HeaderFileExtensions;
|
||||
std::string DefineFlags;
|
||||
|
||||
// Track the value of the computed DEFINITIONS property.
|
||||
|
|
|
@ -528,7 +528,7 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
|
|||
cmSystemTools::ExpandListArgument(this->Sources, sourceFiles);
|
||||
|
||||
const std::vector<std::string>& headerExtensions =
|
||||
makefile->GetHeaderExtensions();
|
||||
makefile->GetCMakeInstance()->GetHeaderExtensions();
|
||||
|
||||
std::map<std::string, std::vector<std::string> > includedUis;
|
||||
std::map<std::string, std::vector<std::string> > skippedUis;
|
||||
|
|
|
@ -167,8 +167,10 @@ bool cmSourceFile::FindFullPath(std::string* error)
|
|||
{
|
||||
tryDirs[0] = "";
|
||||
}
|
||||
const std::vector<std::string>& srcExts = mf->GetSourceExtensions();
|
||||
const std::vector<std::string>& hdrExts = mf->GetHeaderExtensions();
|
||||
const std::vector<std::string>& srcExts =
|
||||
mf->GetCMakeInstance()->GetSourceExtensions();
|
||||
std::vector<std::string> hdrExts =
|
||||
mf->GetCMakeInstance()->GetHeaderExtensions();
|
||||
for(const char* const* di = tryDirs; *di; ++di)
|
||||
{
|
||||
std::string tryPath = this->Location.GetDirectory();
|
||||
|
|
|
@ -121,8 +121,10 @@ void cmSourceFileLocation::UpdateExtension(const std::string& name)
|
|||
// The global generator checks extensions of enabled languages.
|
||||
cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
|
||||
cmMakefile const* mf = this->Makefile;
|
||||
const std::vector<std::string>& srcExts = mf->GetSourceExtensions();
|
||||
const std::vector<std::string>& hdrExts = mf->GetHeaderExtensions();
|
||||
const std::vector<std::string>& srcExts =
|
||||
mf->GetCMakeInstance()->GetSourceExtensions();
|
||||
const std::vector<std::string>& hdrExts =
|
||||
mf->GetCMakeInstance()->GetHeaderExtensions();
|
||||
if(!gg->GetLanguageFromExtension(ext.c_str()).empty() ||
|
||||
std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end() ||
|
||||
std::find(hdrExts.begin(), hdrExts.end(), ext) != hdrExts.end())
|
||||
|
@ -193,12 +195,14 @@ cmSourceFileLocation
|
|||
// disk. One of these must match if loc refers to this source file.
|
||||
std::string const& ext = this->Name.substr(loc.Name.size()+1);
|
||||
cmMakefile const* mf = this->Makefile;
|
||||
const std::vector<std::string>& srcExts = mf->GetSourceExtensions();
|
||||
const std::vector<std::string>& srcExts =
|
||||
mf->GetCMakeInstance()->GetSourceExtensions();
|
||||
if(std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
const std::vector<std::string>& hdrExts = mf->GetHeaderExtensions();
|
||||
std::vector<std::string> hdrExts =
|
||||
mf->GetCMakeInstance()->GetHeaderExtensions();
|
||||
if(std::find(hdrExts.begin(), hdrExts.end(), ext) != hdrExts.end())
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -165,6 +165,30 @@ cmake::cmake()
|
|||
|
||||
// Make sure we can capture the build tool output.
|
||||
cmSystemTools::EnableVSConsoleOutput();
|
||||
|
||||
// Set up a list of source and header extensions
|
||||
// these are used to find files when the extension
|
||||
// is not given
|
||||
// The "c" extension MUST precede the "C" extension.
|
||||
this->SourceFileExtensions.push_back( "c" );
|
||||
this->SourceFileExtensions.push_back( "C" );
|
||||
|
||||
this->SourceFileExtensions.push_back( "c++" );
|
||||
this->SourceFileExtensions.push_back( "cc" );
|
||||
this->SourceFileExtensions.push_back( "cpp" );
|
||||
this->SourceFileExtensions.push_back( "cxx" );
|
||||
this->SourceFileExtensions.push_back( "m" );
|
||||
this->SourceFileExtensions.push_back( "M" );
|
||||
this->SourceFileExtensions.push_back( "mm" );
|
||||
|
||||
this->HeaderFileExtensions.push_back( "h" );
|
||||
this->HeaderFileExtensions.push_back( "hh" );
|
||||
this->HeaderFileExtensions.push_back( "h++" );
|
||||
this->HeaderFileExtensions.push_back( "hm" );
|
||||
this->HeaderFileExtensions.push_back( "hpp" );
|
||||
this->HeaderFileExtensions.push_back( "hxx" );
|
||||
this->HeaderFileExtensions.push_back( "in" );
|
||||
this->HeaderFileExtensions.push_back( "txx" );
|
||||
}
|
||||
|
||||
cmake::~cmake()
|
||||
|
|
|
@ -182,6 +182,11 @@ class cmake
|
|||
///! get the cmCachemManager used by this invocation of cmake
|
||||
cmCacheManager *GetCacheManager() { return this->CacheManager; }
|
||||
|
||||
const std::vector<std::string>& GetSourceExtensions() const
|
||||
{return this->SourceFileExtensions;}
|
||||
const std::vector<std::string>& GetHeaderExtensions() const
|
||||
{return this->HeaderFileExtensions;}
|
||||
|
||||
/**
|
||||
* Given a variable name, return its value (as a string).
|
||||
*/
|
||||
|
@ -391,6 +396,8 @@ private:
|
|||
std::string CheckStampFile;
|
||||
std::string CheckStampList;
|
||||
std::string VSSolutionFile;
|
||||
std::vector<std::string> SourceFileExtensions;
|
||||
std::vector<std::string> HeaderFileExtensions;
|
||||
bool ClearBuildSystem;
|
||||
bool DebugTryCompile;
|
||||
cmFileTimeComparison* FileComparison;
|
||||
|
|
Loading…
Reference in New Issue