summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2001-03-23 19:27:02 (GMT)
committerBrad King <brad.king@kitware.com>2001-03-23 19:27:02 (GMT)
commit9b079becdf11669f9fffd1beb9e89582d667c961 (patch)
tree9e5f0972fdef9a15deba15eaa97cb8fb3fb147ee
parent408cad388a63c6bede9e137c08f3ec57c0e4833b (diff)
downloadCMake-9b079becdf11669f9fffd1beb9e89582d667c961.zip
CMake-9b079becdf11669f9fffd1beb9e89582d667c961.tar.gz
CMake-9b079becdf11669f9fffd1beb9e89582d667c961.tar.bz2
ENH: Added support for CABLE_SOURCE_FILES to refer to files that are not in the current directory. The include path is searched for the files.
-rw-r--r--Source/cmCableSourceFilesCommand.cxx45
-rw-r--r--Source/cmCableSourceFilesCommand.h3
2 files changed, 41 insertions, 7 deletions
diff --git a/Source/cmCableSourceFilesCommand.cxx b/Source/cmCableSourceFilesCommand.cxx
index d41dcc8..4665602 100644
--- a/Source/cmCableSourceFilesCommand.cxx
+++ b/Source/cmCableSourceFilesCommand.cxx
@@ -48,17 +48,13 @@ void cmCableSourceFilesCommand::WriteConfiguration() const
cmRegularExpression needCdataBlock("[&<>]");
- // Look for the files on a path relative to the current CMakeLists.txt.
- std::string curPath = m_Makefile->GetCurrentDirectory();
- curPath += "/";
-
os << indent << "<Headers>" << std::endl;
for(Entries::const_iterator f = m_Entries.begin();
f != m_Entries.end(); ++f)
{
// Look for the normal include file.
std::string header = *f+".h";
- if(cmSystemTools::FileExists((curPath+header).c_str()))
+ if(this->SourceFileExists(header))
{
os << indent << " <File name=\"" << header.c_str() << "\"/>"
<< std::endl;
@@ -70,7 +66,7 @@ void cmCableSourceFilesCommand::WriteConfiguration() const
// Look for an instantiation file.
std::string txx = *f+".txx";
- if(cmSystemTools::FileExists((curPath+txx).c_str()))
+ if(this->SourceFileExists(txx))
{
os << indent << " <File name=\"" << txx.c_str()
<< "\" purpose=\"instantiate\"/>" << std::endl;
@@ -78,3 +74,40 @@ void cmCableSourceFilesCommand::WriteConfiguration() const
}
os << indent << "</Headers>" << std::endl;
}
+
+
+/**
+ * Search the include path for the specified file.
+ */
+bool cmCableSourceFilesCommand::SourceFileExists(const std::string& name) const
+{
+ // We must locate the file in the include path so that we can detect
+ // its extension, and whether there is more than one to find.
+ std::string file = name;
+ m_Makefile->ExpandVariablesInString(file);
+
+ // See if the file just exists here. The compiler's search path will
+ // locate it.
+ if(cmSystemTools::FileExists(file.c_str()))
+ {
+ return true;
+ }
+
+ // We must look for the file in the include search path.
+ const std::vector<std::string>& includeDirectories =
+ m_Makefile->GetIncludeDirectories();
+
+ for(std::vector<std::string>::const_iterator dir = includeDirectories.begin();
+ dir != includeDirectories.end(); ++dir)
+ {
+ std::string path = *dir + "/";
+ m_Makefile->ExpandVariablesInString(path);
+ if(cmSystemTools::FileExists((path+file).c_str()))
+ {
+ return true;
+ }
+ }
+
+ // We couldn't locate the source file.
+ return false;
+}
diff --git a/Source/cmCableSourceFilesCommand.h b/Source/cmCableSourceFilesCommand.h
index 866eb50..4aefeb0 100644
--- a/Source/cmCableSourceFilesCommand.h
+++ b/Source/cmCableSourceFilesCommand.h
@@ -68,7 +68,8 @@ public:
}
virtual void WriteConfiguration() const;
-
+ bool SourceFileExists(const std::string&) const;
+
cmTypeMacro(cmCableSourceFilesCommand, cmCableCommand);
protected:
typedef cmCablePackageEntryCommand::Entries Entries;