cmSubdirCommand.cxx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 = std::string(this->Makefile->GetCurrentDirectory()) +
  40. "/" + i->c_str();
  41. if (cmSystemTools::FileIsDirectory(srcPath.c_str()))
  42. {
  43. std::string binPath =
  44. std::string(this->Makefile->GetCurrentOutputDirectory()) +
  45. "/" + i->c_str();
  46. this->Makefile->AddSubDirectory(srcPath.c_str(), binPath.c_str(),
  47. intoplevel, preorder, false);
  48. }
  49. // otherwise it is a full path
  50. else if ( cmSystemTools::FileIsDirectory(i->c_str()) )
  51. {
  52. // we must compute the binPath from the srcPath, we just take the last
  53. // element from the source path and use that
  54. std::string binPath =
  55. std::string(this->Makefile->GetCurrentOutputDirectory()) +
  56. "/" + cmSystemTools::GetFilenameName(i->c_str());
  57. this->Makefile->AddSubDirectory(i->c_str(), binPath.c_str(),
  58. intoplevel, preorder, false);
  59. }
  60. else
  61. {
  62. std::string error = "Incorrect SUBDIRS command. Directory: ";
  63. error += *i + " does not exists.";
  64. this->SetError(error.c_str());
  65. res = false;
  66. }
  67. }
  68. return res;
  69. }