cmSubdirCommand.cxx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 "cmSubdirCommand.h"
  14. // cmSubdirCommand
  15. bool cmSubdirCommand::InitialPass(std::vector<std::string> const& args)
  16. {
  17. if(args.size() < 1 )
  18. {
  19. this->SetError("called with incorrect number of arguments");
  20. return false;
  21. }
  22. bool res = true;
  23. bool intoplevel = true;
  24. bool preorder = false;
  25. for(std::vector<std::string>::const_iterator i = args.begin();
  26. i != args.end(); ++i)
  27. {
  28. if(*i == "EXCLUDE_FROM_ALL")
  29. {
  30. intoplevel = false;
  31. continue;
  32. }
  33. if(*i == "PREORDER")
  34. {
  35. preorder = true;
  36. continue;
  37. }
  38. // if they specified a relative path then compute the full
  39. std::string srcPath =
  40. std::string(this->Makefile->GetCurrentDirectory()) +
  41. "/" + i->c_str();
  42. if (cmSystemTools::FileIsDirectory(srcPath.c_str()))
  43. {
  44. std::string binPath =
  45. std::string(this->Makefile->GetCurrentOutputDirectory()) +
  46. "/" + i->c_str();
  47. this->Makefile->AddSubDirectory(srcPath.c_str(), binPath.c_str(),
  48. intoplevel, preorder, false);
  49. }
  50. // otherwise it is a full path
  51. else if ( cmSystemTools::FileIsDirectory(i->c_str()) )
  52. {
  53. // we must compute the binPath from the srcPath, we just take the last
  54. // element from the source path and use that
  55. std::string binPath =
  56. std::string(this->Makefile->GetCurrentOutputDirectory()) +
  57. "/" + cmSystemTools::GetFilenameName(i->c_str());
  58. this->Makefile->AddSubDirectory(i->c_str(), binPath.c_str(),
  59. intoplevel, preorder, false);
  60. }
  61. else
  62. {
  63. std::string error = "Incorrect SUBDIRS command. Directory: ";
  64. error += *i + " does not exists.";
  65. this->SetError(error.c_str());
  66. res = false;
  67. }
  68. }
  69. return res;
  70. }