cmLinkLibrariesCommand.cxx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 "cmMakefile.h"
  5. class cmExecutionStatus;
  6. // cmLinkLibrariesCommand
  7. bool cmLinkLibrariesCommand::InitialPass(std::vector<std::string> const& args,
  8. cmExecutionStatus&)
  9. {
  10. if (args.empty()) {
  11. return true;
  12. }
  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. this->SetError("The \"debug\" argument must be followed by "
  20. "a library");
  21. return false;
  22. }
  23. this->Makefile->AppendProperty("LINK_LIBRARIES", "debug");
  24. } else if (*i == "optimized") {
  25. ++i;
  26. if (i == args.end()) {
  27. this->SetError("The \"optimized\" argument must be followed by "
  28. "a library");
  29. return false;
  30. }
  31. this->Makefile->AppendProperty("LINK_LIBRARIES", "optimized");
  32. }
  33. this->Makefile->AppendProperty("LINK_LIBRARIES", i->c_str());
  34. }
  35. return true;
  36. }