cmIncludeCommand.cxx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. // cmIncludeCommand
  13. bool cmIncludeCommand::InitialPass(std::vector<std::string> const& argsIn)
  14. {
  15. if (argsIn.size()< 1 || argsIn.size() > 2)
  16. {
  17. this->SetError("called with wrong number of arguments. "
  18. "Include only takes one file.");
  19. }
  20. std::vector<std::string> args = argsIn;
  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. }