cmIncludeCommand.cxx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2000 National Library of Medicine
  8. All rights reserved.
  9. See COPYRIGHT.txt for copyright details.
  10. =========================================================================*/
  11. #include "cmIncludeCommand.h"
  12. #include <iostream.h>
  13. // cmIncludeCommand
  14. bool cmIncludeCommand::InitialPass(std::vector<std::string>& args)
  15. {
  16. if (args.size()< 1 || args.size() > 2)
  17. {
  18. this->SetError("called with wrong number of arguments. "
  19. "Include only takes one file.");
  20. }
  21. m_Makefile->ExpandVariablesInString( args[0]);
  22. bool exists = cmSystemTools::FileExists(args[0].c_str());
  23. if(args.size() == 2 && args[1] == "OPTIONAL" && !exists)
  24. {
  25. return true;
  26. }
  27. if(!exists)
  28. {
  29. std::string error = "Include file not found: " + args[0] + "\n";
  30. this->SetError(error.c_str());
  31. return false;
  32. }
  33. m_Makefile->ReadListFile( m_Makefile->GetCurrentListFile(),
  34. args[0].c_str());
  35. return true;
  36. }