cmLinkLibrariesCommand.cxx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmLinkLibrariesCommand.h"
  4. #include "cmExecutionStatus.h"
  5. #include "cmMakefile.h"
  6. bool cmLinkLibrariesCommand(std::vector<std::string> const& args,
  7. cmExecutionStatus& status)
  8. {
  9. if (args.empty()) {
  10. return true;
  11. }
  12. cmMakefile& mf = status.GetMakefile();
  13. // add libraries, note that there is an optional prefix
  14. // of debug and optimized than can be used
  15. for (auto i = args.begin(); i != args.end(); ++i) {
  16. if (*i == "debug") {
  17. ++i;
  18. if (i == args.end()) {
  19. status.SetError("The \"debug\" argument must be followed by "
  20. "a library");
  21. return false;
  22. }
  23. mf.AppendProperty("LINK_LIBRARIES", "debug");
  24. } else if (*i == "optimized") {
  25. ++i;
  26. if (i == args.end()) {
  27. status.SetError("The \"optimized\" argument must be followed by "
  28. "a library");
  29. return false;
  30. }
  31. mf.AppendProperty("LINK_LIBRARIES", "optimized");
  32. }
  33. mf.AppendProperty("LINK_LIBRARIES", i->c_str());
  34. }
  35. return true;
  36. }