diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2001-06-21 14:36:01 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2001-06-21 14:36:01 (GMT) |
commit | 43c2a895689129cfdf424d8877cd35ad05433dc7 (patch) | |
tree | 4a916154f226a5f877463b4a41275ae2c6b96e78 | |
parent | 3221b4e3febe95e8db500ccd2062daa08154e381 (diff) | |
download | CMake-43c2a895689129cfdf424d8877cd35ad05433dc7.zip CMake-43c2a895689129cfdf424d8877cd35ad05433dc7.tar.gz CMake-43c2a895689129cfdf424d8877cd35ad05433dc7.tar.bz2 |
ENH: add optional include and only allow one file per INCLUDE
-rw-r--r-- | Source/cmIncludeCommand.cxx | 22 | ||||
-rw-r--r-- | Source/cmIncludeCommand.h | 3 |
2 files changed, 17 insertions, 8 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; } diff --git a/Source/cmIncludeCommand.h b/Source/cmIncludeCommand.h index 99f9bd1..c60fbef 100644 --- a/Source/cmIncludeCommand.h +++ b/Source/cmIncludeCommand.h @@ -69,7 +69,8 @@ public: virtual const char* GetFullDocumentation() { return - "INCLUDE(file1 file2)\n"; + "INCLUDE(file1 [OPTIONAL])\nIf OPTIONAL is present, then do not complain " + "if the file does not exist."; } cmTypeMacro(cmIncludeCommand, cmCommand); |