summaryrefslogtreecommitdiffstats
path: root/Source/cmIncludeCommand.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmIncludeCommand.cxx')
-rw-r--r--Source/cmIncludeCommand.cxx22
1 files changed, 15 insertions, 7 deletions
diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx
index bfbcb05..1b440de 100644
--- a/Source/cmIncludeCommand.cxx
+++ b/Source/cmIncludeCommand.cxx
@@ -20,18 +20,26 @@
// cmIncludeCommand
bool cmIncludeCommand::InitialPass(std::vector<std::string>& args)
{
- if (args.size()< 1)
+ if (args.size()< 1 || args.size() > 2)
{
- this->SetError("called with wrong number of arguments.");
+ this->SetError("called with wrong number of arguments. "
+ "Include only takes one file.");
}
- for( unsigned int i=0; i< args.size(); i++)
+ m_Makefile->ExpandVariablesInString( args[0]);
+ bool exists = cmSystemTools::FileExists(args[0].c_str());
+ if(args.size() == 2 && args[1] == "OPTIONAL" && !exists)
{
- m_Makefile->ExpandVariablesInString( args[i]);
- m_Makefile->ReadListFile( m_Makefile->GetCurrentListFile(),
- args[i].c_str());
+ return true;
}
-
+ if(!exists)
+ {
+ std::string error = "Include file not found: " + args[0];
+ this->SetError(error.c_str());
+ return false;
+ }
+ m_Makefile->ReadListFile( m_Makefile->GetCurrentListFile(),
+ args[0].c_str());
return true;
}