summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorAnonymous <kitware@kitware.com>2001-04-30 14:52:58 (GMT)
committerAnonymous <kitware@kitware.com>2001-04-30 14:52:58 (GMT)
commitd6fae5faf0ec5f0a4d4e4d12424b92c7a6fde22a (patch)
treed31b4f767866387ee4864210fe26515ad22208ce /Source/cmMakefile.cxx
parent2da0c57d46d5b68e19b60c4e6560fbd80f808ab0 (diff)
downloadCMake-d6fae5faf0ec5f0a4d4e4d12424b92c7a6fde22a.zip
CMake-d6fae5faf0ec5f0a4d4e4d12424b92c7a6fde22a.tar.gz
CMake-d6fae5faf0ec5f0a4d4e4d12424b92c7a6fde22a.tar.bz2
New command: INCLUDE(somefile.txt)
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx81
1 files changed, 54 insertions, 27 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index fa26995..11d0a26 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -190,48 +190,75 @@ void cmMakefile::Print() const
// Parse the given CMakeLists.txt file into a list of classes.
// Reads in current CMakeLists file and all parent CMakeLists files
// executing all inherited commands in the parents
-bool cmMakefile::ReadListFile(const char* filename)
-{
- // is there a parent CMakeLists file that does not go beyond the
- // Home directory? if so recurse and read in that List file
- std::string parentList = this->GetParentListFileName(filename);
- if (parentList != "")
- {
- // save the current directory
- std::string srcdir = m_cmCurrentDirectory;
- std::string bindir = m_CurrentOutputDirectory;
- // compute the new current directories
- std::string::size_type pos = m_cmCurrentDirectory.rfind('/');
- if(pos != std::string::npos)
- {
- m_cmCurrentDirectory = m_cmCurrentDirectory.substr(0, pos);
- }
- pos = m_CurrentOutputDirectory.rfind('/');
- if(pos != std::string::npos)
- {
- m_CurrentOutputDirectory = m_CurrentOutputDirectory.substr(0, pos);
- }
- this->ReadListFile(parentList.c_str());
- // restore the current directory
- m_cmCurrentDirectory = srcdir;
- m_CurrentOutputDirectory = bindir;
+//
+// if external is non-zero, this means that we have branched to grab some
+// commands from a remote list-file (that is, the equivalent of a
+// #include has been called). We DO NOT look at the parents of this
+// list-file, and for all other purposes, the name of this list-file
+// is "filename" and not "external".
+bool cmMakefile::ReadListFile(const char* filename, const char* external)
+{
+
+ // keep track of the current file being read
+ m_cmCurrentListFile= filename;
+
+ // if this is not a remote makefile
+ // (if it were, this would be called from the "filename" call,
+ // rather than the "external" call)
+ if (!external)
+ {
+ // is there a parent CMakeLists file that does not go beyond the
+ // Home directory? if so recurse and read in that List file
+ std::string parentList = this->GetParentListFileName(filename);
+ if (parentList != "")
+ {
+ // save the current directory
+ std::string srcdir = m_cmCurrentDirectory;
+ std::string bindir = m_CurrentOutputDirectory;
+ // compute the new current directories
+ std::string::size_type pos = m_cmCurrentDirectory.rfind('/');
+ if(pos != std::string::npos)
+ {
+ m_cmCurrentDirectory = m_cmCurrentDirectory.substr(0, pos);
+ }
+ pos = m_CurrentOutputDirectory.rfind('/');
+ if(pos != std::string::npos)
+ {
+ m_CurrentOutputDirectory = m_CurrentOutputDirectory.substr(0, pos);
+ }
+ this->ReadListFile(parentList.c_str());
+ // restore the current directory
+ m_cmCurrentDirectory = srcdir;
+ m_CurrentOutputDirectory = bindir;
+ }
}
// are we at the start CMakeLists file or are we processing a parent
// lists file
+ //
+ // this might, or might not be true, irrespective if we are
+ // off looking at an external makefile.
bool inheriting = (m_cmCurrentDirectory != m_cmStartDirectory);
// Now read the input file
- std::ifstream fin(filename);
+ const char *filenametoread= filename;
+
+ if( external)
+ filenametoread= external;
+
+ std::ifstream fin(filenametoread);
if(!fin)
{
- cmSystemTools::Error("error can not open file ", filename);
+ cmSystemTools::Error("error can not open file ", filenametoread);
return false;
}
std::string name;
std::vector<std::string> arguments;
while ( fin )
{
+ // add this list file to the list of dependencies
+ m_ListFiles.push_back( filenametoread);
+
if(cmSystemTools::ParseFunction(fin, name, arguments) &&
!this->IsFunctionBlocked(name.c_str(),arguments))
{