cmLinkDirectoriesCommand.cxx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 "cmLinkDirectoriesCommand.h"
  11. // cmLinkDirectoriesCommand
  12. bool cmLinkDirectoriesCommand
  13. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  14. {
  15. if(args.size() < 1 )
  16. {
  17. return true;
  18. }
  19. for(std::vector<std::string>::const_iterator i = args.begin();
  20. i != args.end(); ++i)
  21. {
  22. this->AddLinkDir(*i);
  23. }
  24. return true;
  25. }
  26. //----------------------------------------------------------------------------
  27. void cmLinkDirectoriesCommand::AddLinkDir(std::string const& dir)
  28. {
  29. std::string unixPath = dir;
  30. cmSystemTools::ConvertToUnixSlashes(unixPath);
  31. if(!cmSystemTools::FileIsFullPath(unixPath.c_str()))
  32. {
  33. bool convertToAbsolute = false;
  34. std::ostringstream e;
  35. e << "This command specifies the relative path\n"
  36. << " " << unixPath << "\n"
  37. << "as a link directory.\n";
  38. cmPolicies* policies = this->Makefile->GetPolicies();
  39. switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0015))
  40. {
  41. case cmPolicies::WARN:
  42. e << policies->GetPolicyWarning(cmPolicies::CMP0015);
  43. this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, e.str());
  44. case cmPolicies::OLD:
  45. // OLD behavior does not convert
  46. break;
  47. case cmPolicies::REQUIRED_IF_USED:
  48. case cmPolicies::REQUIRED_ALWAYS:
  49. e << policies->GetRequiredPolicyError(cmPolicies::CMP0015);
  50. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  51. case cmPolicies::NEW:
  52. // NEW behavior converts
  53. convertToAbsolute = true;
  54. break;
  55. }
  56. if (convertToAbsolute)
  57. {
  58. std::string tmp = this->Makefile->GetStartDirectory();
  59. tmp += "/";
  60. tmp += unixPath;
  61. unixPath = tmp;
  62. }
  63. }
  64. this->Makefile->AddLinkDirectory(unixPath);
  65. }