cmSubdirCommand.cxx 2.2 KB

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