cmLinkDirectoriesCommand.cxx 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0015))
  39. {
  40. case cmPolicies::WARN:
  41. e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0015);
  42. this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, e.str());
  43. case cmPolicies::OLD:
  44. // OLD behavior does not convert
  45. break;
  46. case cmPolicies::REQUIRED_IF_USED:
  47. case cmPolicies::REQUIRED_ALWAYS:
  48. e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0015);
  49. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  50. case cmPolicies::NEW:
  51. // NEW behavior converts
  52. convertToAbsolute = true;
  53. break;
  54. }
  55. if (convertToAbsolute)
  56. {
  57. std::string tmp = this->Makefile->GetCurrentSourceDirectory();
  58. tmp += "/";
  59. tmp += unixPath;
  60. unixPath = tmp;
  61. }
  62. }
  63. this->Makefile->AppendProperty("LINK_DIRECTORIES", unixPath.c_str());
  64. }