cmLinkDirectoriesCommand.cxx 2.2 KB

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