cmSubdirCommand.cxx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. for(std::vector<std::string>::const_iterator i = args.begin();
  23. i != args.end(); ++i)
  24. {
  25. if(*i == "EXCLUDE_FROM_ALL")
  26. {
  27. excludeFromAll = true;
  28. continue;
  29. }
  30. if(*i == "PREORDER")
  31. {
  32. // Ignored
  33. continue;
  34. }
  35. // if they specified a relative path then compute the full
  36. std::string srcPath =
  37. std::string(this->Makefile->GetCurrentDirectory()) +
  38. "/" + i->c_str();
  39. if (cmSystemTools::FileIsDirectory(srcPath))
  40. {
  41. std::string binPath =
  42. std::string(this->Makefile->GetCurrentOutputDirectory()) +
  43. "/" + i->c_str();
  44. this->Makefile->AddSubDirectory(srcPath, binPath,
  45. excludeFromAll, false);
  46. }
  47. // otherwise it is a full path
  48. else if ( cmSystemTools::FileIsDirectory(*i) )
  49. {
  50. // we must compute the binPath from the srcPath, we just take the last
  51. // element from the source path and use that
  52. std::string binPath =
  53. std::string(this->Makefile->GetCurrentOutputDirectory()) +
  54. "/" + cmSystemTools::GetFilenameName(*i);
  55. this->Makefile->AddSubDirectory(*i, binPath,
  56. excludeFromAll, false);
  57. }
  58. else
  59. {
  60. std::string error = "Incorrect SUBDIRS command. Directory: ";
  61. error += *i + " does not exist.";
  62. this->SetError(error);
  63. res = false;
  64. }
  65. }
  66. return res;
  67. }