cmSubdirCommand.cxx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmSubdirCommand.h"
  11. // cmSubdirCommand
  12. bool cmSubdirCommand
  13. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  14. {
  15. if(args.size() < 1 )
  16. {
  17. this->SetError("called with incorrect number of arguments");
  18. return false;
  19. }
  20. bool res = true;
  21. bool excludeFromAll = false;
  22. bool preorder = false;
  23. for(std::vector<std::string>::const_iterator i = args.begin();
  24. i != args.end(); ++i)
  25. {
  26. if(*i == "EXCLUDE_FROM_ALL")
  27. {
  28. excludeFromAll = true;
  29. continue;
  30. }
  31. if(*i == "PREORDER")
  32. {
  33. preorder = true;
  34. continue;
  35. }
  36. // if they specified a relative path then compute the full
  37. std::string srcPath =
  38. std::string(this->Makefile->GetCurrentDirectory()) +
  39. "/" + i->c_str();
  40. if (cmSystemTools::FileIsDirectory(srcPath))
  41. {
  42. std::string binPath =
  43. std::string(this->Makefile->GetCurrentOutputDirectory()) +
  44. "/" + i->c_str();
  45. this->Makefile->AddSubDirectory(srcPath, binPath,
  46. excludeFromAll, preorder, false);
  47. }
  48. // otherwise it is a full path
  49. else if ( cmSystemTools::FileIsDirectory(*i) )
  50. {
  51. // we must compute the binPath from the srcPath, we just take the last
  52. // element from the source path and use that
  53. std::string binPath =
  54. std::string(this->Makefile->GetCurrentOutputDirectory()) +
  55. "/" + cmSystemTools::GetFilenameName(*i);
  56. this->Makefile->AddSubDirectory(*i, binPath,
  57. excludeFromAll, preorder, false);
  58. }
  59. else
  60. {
  61. std::string error = "Incorrect SUBDIRS command. Directory: ";
  62. error += *i + " does not exist.";
  63. this->SetError(error);
  64. res = false;
  65. }
  66. }
  67. return res;
  68. }