cmIncludeCommand.cxx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html 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& args)
  16. {
  17. if (args.size()< 1 || args.size() > 2)
  18. {
  19. this->SetError("called with wrong number of arguments. "
  20. "Include only takes one file.");
  21. return false;
  22. }
  23. bool optional = false;
  24. std::string fname = args[0].c_str();
  25. if(args.size() == 2)
  26. {
  27. optional = args[1] == "OPTIONAL";
  28. }
  29. if(!cmSystemTools::FileIsFullPath(fname.c_str()))
  30. {
  31. // Not a path. Maybe module.
  32. std::string module = fname;
  33. module += ".cmake";
  34. std::string mfile = this->Makefile->GetModulesFile(module.c_str());
  35. if ( mfile.size() )
  36. {
  37. fname = mfile.c_str();
  38. }
  39. }
  40. bool readit =
  41. this->Makefile->ReadListFile( this->Makefile->GetCurrentListFile(),
  42. fname.c_str() );
  43. if(!optional && !readit && !cmSystemTools::GetFatalErrorOccured())
  44. {
  45. std::string m = "Could not find include file: ";
  46. m += fname;
  47. this->SetError(m.c_str());
  48. return false;
  49. }
  50. return true;
  51. }