summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorAmitha Perera <perera@cs.rpi.edu>2001-07-16 22:40:42 (GMT)
committerAmitha Perera <perera@cs.rpi.edu>2001-07-16 22:40:42 (GMT)
commite169953e923907706439c60033ce983729c2e404 (patch)
treef12edb22a3b64f621ea7d049312ec1a9102ee54e /Source
parentfdfe7a357e38f40d768e24412f7e49b7880c0fcc (diff)
downloadCMake-e169953e923907706439c60033ce983729c2e404.zip
CMake-e169953e923907706439c60033ce983729c2e404.tar.gz
CMake-e169953e923907706439c60033ce983729c2e404.tar.bz2
ENH: Source and header file extensions are in variables in cmMakefile.
AUX_SOURCE_DIRECTORY will only add files that have a "source" extension.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmAuxSourceDirectoryCommand.cxx35
-rw-r--r--Source/cmMakefile.cxx9
-rw-r--r--Source/cmMakefile.h13
-rw-r--r--Source/cmSourceFile.cxx104
-rw-r--r--Source/cmSourceFile.h12
-rw-r--r--Source/cmSourceFilesCommand.cxx8
-rw-r--r--Source/cmSourceFilesRemoveCommand.cxx4
-rw-r--r--Source/cmTarget.cxx4
8 files changed, 105 insertions, 84 deletions
diff --git a/Source/cmAuxSourceDirectoryCommand.cxx b/Source/cmAuxSourceDirectoryCommand.cxx
index 4f8d19c..1639ce0 100644
--- a/Source/cmAuxSourceDirectoryCommand.cxx
+++ b/Source/cmAuxSourceDirectoryCommand.cxx
@@ -63,21 +63,30 @@ bool cmAuxSourceDirectoryCommand::InitialPass(std::vector<std::string>& args)
for(int i =0; i < numfiles; ++i)
{
std::string file = dir.GetFile(i);
- // ignore files less than f.cxx in length
- if(file.size() > 4)
+ // Split the filename into base and extension
+ std::string::size_type dotpos = file.rfind(".");
+ if( dotpos != std::string::npos )
{
- // Remove the extension
- std::string::size_type dotpos = file.rfind(".");
+ std::string ext = file.substr(dotpos+1);
file = file.substr(0, dotpos);
- std::string fullname = templateDirectory;
- fullname += "/";
- fullname += file;
- // add the file as a class file so
- // depends can be done
- cmSourceFile cmfile;
- cmfile.SetName(fullname.c_str(), m_Makefile->GetCurrentDirectory());
- cmfile.SetIsAnAbstractClass(false);
- m_Makefile->AddSource(cmfile,args[1].c_str());
+ // Process only source files
+ if( file.size() != 0
+ && std::find( m_Makefile->GetSourceExtensions().begin(),
+ m_Makefile->GetSourceExtensions().end(), ext )
+ != m_Makefile->GetSourceExtensions().end() )
+ {
+ std::string fullname = templateDirectory;
+ fullname += "/";
+ fullname += file;
+ // add the file as a class file so
+ // depends can be done
+ cmSourceFile cmfile;
+ cmfile.SetName(fullname.c_str(), m_Makefile->GetCurrentDirectory(),
+ m_Makefile->GetSourceExtensions(),
+ m_Makefile->GetHeaderExtensions());
+ cmfile.SetIsAnAbstractClass(false);
+ m_Makefile->AddSource(cmfile,args[1].c_str());
+ }
}
}
}
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index f449610..9ead3e3 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -57,6 +57,15 @@ cmMakefile::cmMakefile()
m_IncludeFileRegularExpression = "^.*$";
// Setup the default include complaint regular expression (match nothing).
m_ComplainFileRegularExpression = "^$";
+ // Source and header file extensions that we can handle
+ m_SourceFileExtensions.push_back( "cxx" );
+ m_SourceFileExtensions.push_back( "cpp" );
+ m_SourceFileExtensions.push_back( "txx" );
+ m_SourceFileExtensions.push_back( "c" );
+ m_SourceFileExtensions.push_back( "M" );
+ m_SourceFileExtensions.push_back( "m" );
+
+ m_HeaderFileExtensions.push_back( "h" );
m_DefineFlags = " ";
m_MakefileGenerator = 0;
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index f8dfcfc..058e127 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -409,6 +409,17 @@ public:
std::vector<std::string>& GetAuxSourceDirectories()
{return m_AuxSourceDirectories;}
+ //@{
+ /**
+ * Return a list of extensions associated with source and header
+ * files
+ */
+ const std::vector<std::string>& GetSourceExtensions() const
+ {return m_SourceFileExtensions;}
+ const std::vector<std::string>& GetHeaderExtensions() const
+ {return m_HeaderFileExtensions;}
+ //@}
+
/**
* Given a variable name, return its value (as a string).
*/
@@ -510,6 +521,8 @@ protected:
std::string m_IncludeFileRegularExpression;
std::string m_ComplainFileRegularExpression;
+ std::vector<std::string> m_SourceFileExtensions;
+ std::vector<std::string> m_HeaderFileExtensions;
std::string m_DefineFlags;
std::vector<cmSourceGroup> m_SourceGroups;
typedef std::map<std::string, cmCommand*> RegisteredCommandsMap;
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index 2081575..152dc6e 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -48,7 +48,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// The class must be found in dir and end in name.cxx, name.txx,
// name.c or it will be considered a header file only class
// and not included in the build process
-void cmSourceFile::SetName(const char* name, const char* dir)
+void cmSourceFile::SetName(const char* name, const char* dir,
+ const std::vector<std::string>& sourceExts,
+ const std::vector<std::string>& headerExts)
{
m_HeaderFileOnly = true;
@@ -94,81 +96,59 @@ void cmSourceFile::SetName(const char* name, const char* dir)
return;
}
- // Try various extentions
- hname = pathname;
- hname += ".cxx";
- if(cmSystemTools::FileExists(hname.c_str()))
- {
- m_SourceExtension = "cxx";
- m_HeaderFileOnly = false;
- m_FullPath = hname;
- return;
- }
-
- hname = pathname;
- hname += ".c";
- if(cmSystemTools::FileExists(hname.c_str()))
- {
- m_HeaderFileOnly = false;
- m_SourceExtension = "c";
- m_FullPath = hname;
- return;
- }
- hname = pathname;
- hname += ".txx";
- if(cmSystemTools::FileExists(hname.c_str()))
- {
- m_HeaderFileOnly = false;
- m_SourceExtension = "txx";
- m_FullPath = hname;
- return;
- }
- //
- hname = pathname;
- hname += ".cpp";
- if(cmSystemTools::FileExists(hname.c_str()))
+ // Next, try the various source extensions
+ for( std::vector<std::string>::const_iterator ext = sourceExts.begin();
+ ext != sourceExts.end(); ++ext )
{
- m_SourceExtension = "cpp";
- m_HeaderFileOnly = false;
- m_FullPath = hname;
- return;
+ hname = pathname;
+ hname += ".";
+ hname += *ext;
+ if(cmSystemTools::FileExists(hname.c_str()))
+ {
+ m_SourceExtension = *ext;
+ m_HeaderFileOnly = false;
+ m_FullPath = hname;
+ return;
+ }
}
- hname = pathname;
- hname += ".m";
- if(cmSystemTools::FileExists(hname.c_str()))
+ // Finally, try the various header extensions
+ for( std::vector<std::string>::const_iterator ext = headerExts.begin();
+ ext != headerExts.end(); ++ext )
{
- m_SourceExtension = "m";
- m_HeaderFileOnly = false;
- m_FullPath = hname;
- return;
+ hname = pathname;
+ hname += ".";
+ hname += *ext;
+ if(cmSystemTools::FileExists(hname.c_str()))
+ {
+ m_SourceExtension = *ext;
+ m_FullPath = hname;
+ return;
+ }
}
- hname = pathname;
- hname += ".M";
- if(cmSystemTools::FileExists(hname.c_str()))
+ std::string errorMsg = "Tried";
+ for( std::vector<std::string>::const_iterator ext = sourceExts.begin();
+ ext != sourceExts.end(); ++ext )
{
- m_SourceExtension = "M";
- m_HeaderFileOnly = false;
- m_FullPath = hname;
- return;
+ errorMsg += " .";
+ errorMsg += *ext;
}
-
- hname = pathname;
- hname += ".h";
- if(cmSystemTools::FileExists(hname.c_str()))
+ for( std::vector<std::string>::const_iterator ext = headerExts.begin();
+ ext != headerExts.end(); ++ext )
{
- m_SourceExtension = "h";
- m_FullPath = hname;
- return;
+ errorMsg += " .";
+ errorMsg += *ext;
}
+ errorMsg += " for ";
- cmSystemTools::Error("can not find file ", hname.c_str());
- cmSystemTools::Error("Tried .cxx .c .txx .cpp .m .M .h for ", hname.c_str());
+ cmSystemTools::Error("can not find file ", pathname.c_str());
+ cmSystemTools::Error(errorMsg.c_str(), pathname.c_str());
}
+
void cmSourceFile::SetName(const char* name, const char* dir, const char *ext,
- bool hfo)
+ bool hfo)
{
m_HeaderFileOnly = hfo;
m_SourceName = name;
diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h
index 57a5312..538129a 100644
--- a/Source/cmSourceFile.h
+++ b/Source/cmSourceFile.h
@@ -64,15 +64,17 @@ public:
}
/**
- * Set the name of the file, given the directory
- * the file should be in. Various extensions are tried on
- * the name (e.g., .cxx, .cpp) in the directory to find the actual file.
+ * Set the name of the file, given the directory the file should be
+ * in. The various extensions provided are tried on the name
+ * (e.g., cxx, cpp) in the directory to find the actual file.
*/
- void SetName(const char* name, const char* dir);
+ void SetName(const char* name, const char* dir,
+ const std::vector<std::string>& sourceExts,
+ const std::vector<std::string>& headerExts);
/**
* Set the name of the file, given the directory the file should be in. IN
- * this version the extesion is provided in the call. This is useful for
+ * this version the extension is provided in the call. This is useful for
* generated files that do not exist prior to the build.
*/
void SetName(const char* name, const char* dir, const char *ext,
diff --git a/Source/cmSourceFilesCommand.cxx b/Source/cmSourceFilesCommand.cxx
index bc39fc5..778c095 100644
--- a/Source/cmSourceFilesCommand.cxx
+++ b/Source/cmSourceFilesCommand.cxx
@@ -61,11 +61,15 @@ bool cmSourceFilesCommand::InitialPass(std::vector<std::string>& args)
(path.size() > 1 && path[1] == ':'))
{
file.SetName(cmSystemTools::GetFilenameName(copy.c_str()).c_str(),
- path.c_str());
+ path.c_str(),
+ m_Makefile->GetSourceExtensions(),
+ m_Makefile->GetHeaderExtensions());
}
else
{
- file.SetName(i->c_str(), m_Makefile->GetCurrentDirectory());
+ file.SetName(i->c_str(), m_Makefile->GetCurrentDirectory(),
+ m_Makefile->GetSourceExtensions(),
+ m_Makefile->GetHeaderExtensions());
}
m_Makefile->AddSource(file, args[0].c_str());
}
diff --git a/Source/cmSourceFilesRemoveCommand.cxx b/Source/cmSourceFilesRemoveCommand.cxx
index 815c2b9..e43facb 100644
--- a/Source/cmSourceFilesRemoveCommand.cxx
+++ b/Source/cmSourceFilesRemoveCommand.cxx
@@ -52,7 +52,9 @@ bool cmSourceFilesRemoveCommand::InitialPass(std::vector<std::string>& args)
i != args.end(); ++i)
{
cmSourceFile file;
- file.SetName((*i).c_str(), m_Makefile->GetCurrentDirectory());
+ file.SetName((*i).c_str(), m_Makefile->GetCurrentDirectory(),
+ m_Makefile->GetSourceExtensions(),
+ m_Makefile->GetHeaderExtensions());
m_Makefile->RemoveSource(file, args[0].c_str());
}
return true;
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 50a2c17..ea983f9 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -71,7 +71,9 @@ void cmTarget::GenerateSourceFilesFromSourceLists(const cmMakefile &mf)
{
cmSourceFile file;
file.SetIsAnAbstractClass(false);
- file.SetName(temps.c_str(), mf.GetCurrentDirectory());
+ file.SetName(temps.c_str(), mf.GetCurrentDirectory(),
+ mf.GetSourceExtensions(),
+ mf.GetHeaderExtensions());
m_SourceFiles.push_back(file);
}
}