cmIncludeCommand.cxx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Insight Consortium. All rights reserved.
  8. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmIncludeCommand.h"
  14. // cmIncludeCommand
  15. bool cmIncludeCommand::InitialPass(std::vector<std::string> const& argsIn)
  16. {
  17. if (argsIn.size()< 1 || argsIn.size() > 2)
  18. {
  19. this->SetError("called with wrong number of arguments. "
  20. "Include only takes one file.");
  21. }
  22. std::vector<std::string> args = argsIn;
  23. m_Makefile->ExpandVariablesInString( args[0]);
  24. bool exists = cmSystemTools::FileExists(args[0].c_str());
  25. if(args.size() == 2 && args[1] == "OPTIONAL" && !exists)
  26. {
  27. return true;
  28. }
  29. if(!exists)
  30. {
  31. std::string error = "Include file not found: " + args[0] + "\n";
  32. this->SetError(error.c_str());
  33. return false;
  34. }
  35. m_Makefile->ReadListFile( m_Makefile->GetCurrentListFile(),
  36. args[0].c_str());
  37. return true;
  38. }