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>& args)
  14. {
  15. if (args.size()< 1 || args.size() > 2)
  16. {
  17. this->SetError("called with wrong number of arguments. "
  18. "Include only takes one file.");
  19. }
  20. m_Makefile->ExpandVariablesInString( args[0]);
  21. bool exists = cmSystemTools::FileExists(args[0].c_str());
  22. if(args.size() == 2 && args[1] == "OPTIONAL" && !exists)
  23. {
  24. return true;
  25. }
  26. if(!exists)
  27. {
  28. std::string error = "Include file not found: " + args[0] + "\n";
  29. this->SetError(error.c_str());
  30. return false;
  31. }
  32. m_Makefile->ReadListFile( m_Makefile->GetCurrentListFile(),
  33. args[0].c_str());
  34. return true;
  35. }